Method: Module#housing
- Defined in:
- lib/core/facets/module/home.rb
#housing ⇒ Object
Returns all the namespaces of this module according ordered from nearest and moving outwards. The receiver is not contained within the result.
module ::HouseExample
module M
module N
end
end
end
HouseExample.housing #=> [Object]
HouseExample::M.housing #=> [HouseExample, Object]
HouseExample::M::N.housing #=> [HouseExample::M, HouseExample, Object]
Compare this to Module.nesting.
80 81 82 83 84 85 86 87 88 |
# File 'lib/core/facets/module/home.rb', line 80 def housing n = [] name.split(/::/).inject(self) do |mod, cref| c = mod.const_get(cref) ; n.unshift(c) ; c end n << Object # ? n.shift # we really don't need +self+ too. n end |