module Her::Model::Introspection::ClassMethods

@private

Public Instance Methods

her_nearby_class(name) click to toggle source

Finds a class at the same level as this one or at the global level.

@private

# File lib/her/model/introspection.rb, line 41
def her_nearby_class(name)
  her_sibling_class(name) || name.constantize
end

Protected Instance Methods

her_containing_module() click to toggle source

If available, returns the containing Module for this class.

@private

# File lib/her/model/introspection.rb, line 60
def her_containing_module
  return unless name =~ /::/
  name.split("::")[0..-2].join("::").constantize
end
her_sibling_class(name) click to toggle source

Looks for a class at the same level as this one with the given name.

@private

# File lib/her/model/introspection.rb, line 50
def her_sibling_class(name)
  if mod = her_containing_module
    @_her_sibling_class ||= Hash.new { Hash.new }
    @_her_sibling_class[mod][name] ||= "#{mod.name}::#{name}".constantize rescue nil
  end
end