Module: Gemmy::Patches::ObjectPatch::InstanceMethods::Constant

Defined in:
lib/gemmy/patches/object_patch.rb

Instance Method Summary collapse

Instance Method Details

#constant(const) ⇒ Object

facets like Module#const_get accessible at all levels and handles module hierarchy. constant(“Process::Sys”)



195
196
197
198
199
# File 'lib/gemmy/patches/object_patch.rb', line 195

def constant(const)
  const = const.to_s.dup
  base = const.sub!(/^::/, '') ? Object : ( self.kind_of?(Module) ? self : self.class )
  const.split(/::/).inject(base){ |mod, name| mod.const_get(name) }
end