module Sequel::Plugins::Sharding::InstanceMethods
Public Instance Methods
Source
# File lib/sequel/plugins/sharding.rb 68 def set_server?(s) 69 @server ||= s 70 self 71 end
Set the server that this object is tied to, unless it has already been set. Returns self.
Private Instance Methods
Source
# File lib/sequel/plugins/sharding.rb 76 def _apply_association_options(*args) 77 use_server(super) 78 end
Ensure that association datasets are tied to the correct shard.
Calls superclass method
Source
# File lib/sequel/plugins/sharding.rb 81 def _associated_object_loader(opts, dynamic_opts) 82 nil 83 end
Don’t use an associated object loader, as it won’t respect the shard used.
Source
# File lib/sequel/plugins/sharding.rb 86 def _join_table_dataset(opts) 87 use_server(super) 88 end
Ensure that the join table for many_to_many associations uses the correct shard.
Calls superclass method
Source
# File lib/sequel/plugins/sharding.rb 93 def ensure_associated_primary_key(opts, o, *args) 94 o.set_server?(@server) if o.respond_to?(:set_server?) 95 super 96 end
If creating the object by doing add_association
for a many_to_many
association, make sure the associated object is created on the current object’s shard, unless the passed object already has an assigned shard.
Calls superclass method
Source
# File lib/sequel/plugins/sharding.rb 100 def load_with_primary_key_lookup?(opts, dynamic_opts) 101 false 102 end
Don’t use primary key lookup to load associated objects, since that will not respect the current object’s server.