T
T. Onoma
First of all, if class Class inherits class Module then why isn't
append_features defined for Class?
class Whatever
append_features MyModule
end
# => undefined method `append_features' for Whatever:Class (NoMethodError)
But even more nonsensical:
class Module
alias append_features_orig append_features
def append_features(mod)
p mod, mod.class
append_features_orig(mod)
end
end
module MyModule
def wow
puts "You have to be kidding!"
end
end
class Test
include MyModule
end
t = Test.new
t.wow
Produces:
Test
Class
You have to be kidding!
Its my understanding the include passes each Module to append_features, but
that's not what append_features is saying. In fact, according to this
append_features is appending Test to Test, even though it works fine. Please,
tell me I'm over looking the obvious here.
append_features defined for Class?
class Whatever
append_features MyModule
end
# => undefined method `append_features' for Whatever:Class (NoMethodError)
But even more nonsensical:
class Module
alias append_features_orig append_features
def append_features(mod)
p mod, mod.class
append_features_orig(mod)
end
end
module MyModule
def wow
puts "You have to be kidding!"
end
end
class Test
include MyModule
end
t = Test.new
t.wow
Produces:
Test
Class
You have to be kidding!
Its my understanding the include passes each Module to append_features, but
that's not what append_features is saying. In fact, according to this
append_features is appending Test to Test, even though it works fine. Please,
tell me I'm over looking the obvious here.