I
Ian White
Hi Group,
This code:
module Foo
def self.included(base)
base.class_eval <<-end_eval
def self.meth
"Foo"
end
end_eval
end
end
module Bar
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def meth
"Bar"
end
end
end
class A
include Foo
include Bar
end
puts A.meth
produces:
Foo
whereas I would expect it to produce "Bar"
Can anyone explain what's going on here? i.e. Why the latter extend
with Bar doesn't over-write the class method introduced by Foo
Cheers,
Ian White
This code:
module Foo
def self.included(base)
base.class_eval <<-end_eval
def self.meth
"Foo"
end
end_eval
end
end
module Bar
def self.included(base)
base.class_eval do
extend ClassMethods
end
end
module ClassMethods
def meth
"Bar"
end
end
end
class A
include Foo
include Bar
end
puts A.meth
produces:
Foo
whereas I would expect it to produce "Bar"
Can anyone explain what's going on here? i.e. Why the latter extend
with Bar doesn't over-write the class method introduced by Foo
Cheers,
Ian White