Module: ActiveRecord::Delegation::DelegateCache
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
| |
Defined in: | activerecord/lib/active_record/relation/delegation.rb |
Instance Attribute Summary
Instance Method Summary
Instance Attribute Details
#delegate_base_methods (rw)
[ GitHub ]# File 'activerecord/lib/active_record/relation/delegation.rb', line 26
singleton_class.attr_accessor :delegate_base_methods
Instance Method Details
#generate_relation_method(method)
[ GitHub ]# File 'activerecord/lib/active_record/relation/delegation.rb', line 52
def generate_relation_method(method) generated_relation_methods.generate_method(method) end
#generated_relation_methods (private)
[ GitHub ]# File 'activerecord/lib/active_record/relation/delegation.rb', line 63
def generated_relation_methods @generated_relation_methods ||= GeneratedRelationMethods.new.tap do |mod| const_set(:GeneratedRelationMethods, mod) private_constant :GeneratedRelationMethods end end
#include_relation_methods(delegate) (protected)
[ GitHub ]# File 'activerecord/lib/active_record/relation/delegation.rb', line 57
def include_relation_methods(delegate) superclass.include_relation_methods(delegate) unless base_class? delegate.include generated_relation_methods end
#inherited(child_class)
[ GitHub ]# File 'activerecord/lib/active_record/relation/delegation.rb', line 47
def inherited(child_class) child_class.initialize_relation_delegate_cache super end
#initialize_relation_delegate_cache
[ GitHub ]# File 'activerecord/lib/active_record/relation/delegation.rb', line 32
def initialize_relation_delegate_cache @relation_delegate_cache = cache = {} Delegation.delegated_classes.each do |klass| delegate = Class.new(klass) { include ClassSpecificRelation } include_relation_methods(delegate) mangled_name = klass.name.gsub("::", "_") const_set mangled_name, delegate private_constant mangled_name cache[klass] = delegate end end
#relation_delegate_class(klass)
[ GitHub ]# File 'activerecord/lib/active_record/relation/delegation.rb', line 28
def relation_delegate_class(klass) @relation_delegate_cache[klass] end