I used the following hook to check the module that makes the inclusion when I do include Foo:
module Foo
def self.included(includer)
puts includer
end
end
Module#includebehaves differently in the module (where it is commonly used) against the top level. Inside a module selfis a module that is an instance Module. When I invoke the includemodule that performs the inclusion , thatself :
module Bar
puts self
include Foo
end
At the top level of the ruby script, selfthere is main, which is an instance Object. When I call includeat the top level, the module that performs the inclusion,, Objectis a class of thatself :
puts self
include Foo
Can someone explain why?
; to_s inspect , main, Object.new to_s inspect , : #<Object:0x007fae0a87ac48>.