Sha256: 7831d4533c9a077ebc05bbf6e52845c1503d90dd4eb794bfd5995eff49e49433

Contents?: true

Size: 413 Bytes

Versions: 1

Compression:

Stored size: 413 Bytes

Contents

class Module
  def find_const(nested_name)
    self.__nested_constants__[nested_name]
  rescue NameError
    Object::__nested_constants__[nested_name]
  end

  protected  
  def __nested_constants__
    @__nested_constants__ ||= Hash.new do |h,k|
      klass = self
      k.split('::').each do |c|
        klass = klass.const_get(c) unless c.empty?
      end
      h[k] = klass
    end
  end
  
end # class Module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
extlib-0.9.2 lib/extlib/module.rb