Sha256: ddc7e821be6f51ddd45a566584af363b0ba3bf266558cf0481dd0a15d7d07662

Contents?: true

Size: 279 Bytes

Versions: 10

Compression:

Stored size: 279 Bytes

Contents

class Module

  # Show a modules nesting in module namespaces.
  #
  #   A::B::C.nesting  #=> [ A, A::B ]
  #
  # CREDIT: Trans

  def nesting
    n = []
    name.split(/::/).inject(self) do |mod, name|
      c = mod.const_get(name) ; n << c ; c
    end
    return n
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/module/nesting.rb
facets-2.8.3 lib/core/facets/module/nesting.rb
facets-2.8.2 lib/core/facets/module/nesting.rb
facets-2.8.1 lib/core/facets/module/nesting.rb
facets-2.8.0 lib/core/facets/module/nesting.rb
facets-2.7.0 lib/core/facets/module/nesting.rb
facets-2.6.0 lib/core/facets/module/nesting.rb
facets-2.5.1 lib/core/facets/module/nesting.rb
facets-2.5.0 lib/core/facets/module/nesting.rb
facets-2.5.2 lib/core/facets/module/nesting.rb