include Foo
puts a http://xtargets.com
The below code obviously work the way I wish
module Foo
def foo
puts “a”
end
end
class Bar
extend Foo
puts foo
end
however is there any way to get the same effect by using include. I
would like to mix in class and instance methods in one call. It seems
I can do one or the other but not both at the same time. Is that
correct?
class Bar
def self.foo a
Brad
class Bar
extend Foo
puts foo
end
however is there any way to get the same effect by using include. I would
like to mix in class and instance methods in one call. It seems
I can do one or the other but not both at the same time. Is that
correct?
Basically, yes: mixing in a module inserts the module in only one
method lookup path, and a class and its instances generally have very
different lookup paths.
You can use the inherited hook in Module to do both – for example: