module Pipeful::FindConstant


PARENTHETICAL ARGUMENTS TO FUNCTIONS VIA method_missing

Public Instance Methods

find_constant(name, top_level: ::Object) click to toggle source

finds a class/constant by name contained in self or parents up to (and including) top_level

# File lib/pipeful.rb, line 215
def find_constant(name, top_level: ::Object)
  return const_get(name) if constants.include?(name)
  return nil if self == top_level
  module_parent.find_constant(name, top_level: top_level)
end
module_parent() click to toggle source
# File lib/pipeful.rb, line 210
def module_parent
  @module_parent ||= name =~ /::[^:]+\Z/ ? Object.const_get($`) : Object
end