module Gemmy::Patches::ObjectPatch::InstanceMethods::Constant

Public Instance Methods

constant(const) click to toggle source

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

# 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