Class: ActiveRecordShards::AssociationCollectionConnectionSelection::PrimaryReplicaProxy
- Inherits:
-
Object
- Object
- ActiveRecordShards::AssociationCollectionConnectionSelection::PrimaryReplicaProxy
- Defined in:
- lib/active_record_shards/association_collection_connection_selection.rb
Instance Method Summary collapse
-
#initialize(association_collection, which) ⇒ PrimaryReplicaProxy
constructor
A new instance of PrimaryReplicaProxy.
-
#method_missing(method, *args, &block) ⇒ Object
rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing.
Constructor Details
#initialize(association_collection, which) ⇒ PrimaryReplicaProxy
Returns a new instance of PrimaryReplicaProxy.
36 37 38 39 |
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 36 def initialize(association_collection, which) @association_collection = association_collection @which = which end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
41 42 43 44 |
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 41 def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing reflection = @association_collection.proxy_association.reflection reflection.klass.on_cx_switch_block(@which) { @association_collection.send(method, *args, &block) } end |