Is this syntax functionally equivalent
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
to this?
def self.included(base)
base.extend ClassMethods
end
Is this syntax functionally equivalent
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
to this?
def self.included(base)
base.extend ClassMethods
end
The only relevant difference is that only classes respond to "class_eval", whereas both classes and instances respond to "extend".
If you don't plan on using your method with object instances, then they are equivalent, though the second implementation can be used to add instance methods to a particular instance, while the first one cannot.