Module: ActiveRecord::Delegation::ClassMethods
- Defined in:
- lib/active_record/relation/delegation.rb
Overview
:nodoc:
Constant Summary collapse
- @@subclasses =
ThreadSafe::Cache.new(:initial_capacity => 2)
Instance Method Summary collapse
-
#const_missing(name) ⇒ Object
This doesn’t have to be thread-safe.
- #new(klass, *args) ⇒ Object
Instance Method Details
#const_missing(name) ⇒ Object
This doesn’t have to be thread-safe. relation_class_for guarantees that this will only be called exactly once for a given const name.
84 85 86 |
# File 'lib/active_record/relation/delegation.rb', line 84 def const_missing(name) const_set(name, Class.new(self) { include ClassSpecificRelation }) end |
#new(klass, *args) ⇒ Object
76 77 78 79 80 |
# File 'lib/active_record/relation/delegation.rb', line 76 def new(klass, *args) relation = relation_class_for(klass).allocate relation.__send__(:initialize, klass, *args) relation end |