Sha256: 35659b5fd241d0a9697e5b209275083fedd1d3d3b65c66ba3d33a43b6e90beb5

Contents?: true

Size: 280 Bytes

Versions: 6

Compression:

Stored size: 280 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

6 entries across 6 versions & 2 rubygems

Version Path
facets-2.4.1 lib/facets/module/nesting.rb
facets-2.4.2 lib/core/facets/module/nesting.rb
facets-2.4.3 lib/core/facets/module/nesting.rb
facets-2.4.4 lib/core/facets/module/nesting.rb
facets-2.4.5 lib/core/facets/module/nesting.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/module/nesting.rb