module ActiveAny::Delegation::DelegateCache

Public Instance Methods

inherited(child_class) click to toggle source
Calls superclass method
# File lib/active_any/relation/delegation.rb, line 28
def inherited(child_class)
  child_class.initialize_relation_delegate_cache
  super
end
initialize_relation_delegate_cache() click to toggle source
# File lib/active_any/relation/delegation.rb, line 12
def initialize_relation_delegate_cache
  @relation_delegate_cache = cache = {}
  [
    ActiveAny::Relation,
    ActiveAny::Associations::CollectionProxy,
    ActiveAny::AssociationRelation
  ].each do |klass|
    delegate = Class.new(klass) { include ClassSpecificRelation }
    mangled_name = klass.name.gsub('::', '_')
    const_set mangled_name, delegate
    private_constant mangled_name

    cache[klass] = delegate
  end
end
relation_delegate_class(klass) click to toggle source
# File lib/active_any/relation/delegation.rb, line 8
def relation_delegate_class(klass)
  @relation_delegate_cache[klass]
end