Module: ActiveRecordShards::AssociationCollectionConnectionSelection

Defined in:
lib/active_record_shards/association_collection_connection_selection.rb

Defined Under Namespace

Classes: PrimaryReplicaProxy

Instance Method Summary collapse

Instance Method Details

#on_primaryObject



25
26
27
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 25

def on_primary
  PrimaryReplicaProxy.new(self, :primary)
end

#on_primary_if(condition) ⇒ Object



13
14
15
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 13

def on_primary_if(condition)
  condition ? on_primary : self
end

#on_primary_unless(condition) ⇒ Object



17
18
19
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 17

def on_primary_unless(condition)
  on_primary_if(!condition)
end

#on_replicaObject



21
22
23
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 21

def on_replica
  PrimaryReplicaProxy.new(self, :replica)
end

#on_replica_if(condition) ⇒ Object



5
6
7
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 5

def on_replica_if(condition)
  condition ? on_replica : self
end

#on_replica_unless(condition) ⇒ Object



9
10
11
# File 'lib/active_record_shards/association_collection_connection_selection.rb', line 9

def on_replica_unless(condition)
  on_replica_if(!condition)
end