module Sequel::Plugins::Sharding::InstanceMethods

Public Instance Methods

set_server?(s) click to toggle source

Set the server that this object is tied to, unless it has already been set. Returns self.

# File lib/sequel/plugins/sharding.rb, line 69
def set_server?(s)
  @server ||= s
  self
end

Private Instance Methods

_apply_association_options(*args) click to toggle source

Ensure that association datasets are tied to the correct shard.

Calls superclass method
# File lib/sequel/plugins/sharding.rb, line 77
def _apply_association_options(*args)
  use_server(super)
end
_associated_object_loader(opts, dynamic_opts) click to toggle source

Don't use an associated object loader, as it won't respect the shard used.

# File lib/sequel/plugins/sharding.rb, line 82
def _associated_object_loader(opts, dynamic_opts)
  nil
end
_associated_objects_use_same_server?() click to toggle source

Mark that associated objects should use the same server.

# File lib/sequel/plugins/sharding.rb, line 87
def _associated_objects_use_same_server?
  true
end
_join_table_dataset(opts) click to toggle source

Ensure that the join table for many_to_many associations uses the correct shard.

Calls superclass method
# File lib/sequel/plugins/sharding.rb, line 92
def _join_table_dataset(opts)
  use_server(super)
end
ensure_associated_primary_key(opts, o, *args) click to toggle source

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
# File lib/sequel/plugins/sharding.rb, line 99
def ensure_associated_primary_key(opts, o, *args)
  o.set_server?(@server) if o.respond_to?(:set_server?)
  super
end
load_with_primary_key_lookup?(opts, dynamic_opts) click to toggle source

Don't use primary key lookup to load associated objects, since that will not respect the current object's server.

# File lib/sequel/plugins/sharding.rb, line 106
def load_with_primary_key_lookup?(opts, dynamic_opts)
  false
end