Module: Sequel::Plugins::Sharding::ClassMethods
- Defined in:
- lib/sequel/plugins/sharding.rb
Instance Method Summary collapse
-
#create_using_server(s, values = {}, &block) ⇒ Object
Create a new object on the given shard s.
-
#eager_loading_dataset(opts, ds, select, associations, eager_options = OPTS) ⇒ Object
When eagerly loading, if the current dataset has a defined shard and the dataset that you will be using to get the associated records does not, use the current dataset’s shard for the associated dataset.
-
#new_using_server(s, values = {}, &block) ⇒ Object
Return a newly instantiated object that is tied to the given shard s.
Instance Method Details
#create_using_server(s, values = {}, &block) ⇒ Object
Create a new object on the given shard s.
23 24 25 |
# File 'lib/sequel/plugins/sharding.rb', line 23 def create_using_server(s, values={}, &block) new_using_server(s, values, &block).save end |
#eager_loading_dataset(opts, ds, select, associations, eager_options = OPTS) ⇒ Object
When eagerly loading, if the current dataset has a defined shard and the dataset that you will be using to get the associated records does not, use the current dataset’s shard for the associated dataset.
30 31 32 33 34 35 36 |
# File 'lib/sequel/plugins/sharding.rb', line 30 def eager_loading_dataset(opts, ds, select, associations, =OPTS) ds = super(opts, ds, select, associations, ) if !ds.opts[:server] and s = [:self] and server = s.opts[:server] ds = ds.server(server) end ds end |
#new_using_server(s, values = {}, &block) ⇒ Object
Return a newly instantiated object that is tied to the given shard s. When the object is saved, a record will be inserted on shard s.
41 42 43 |
# File 'lib/sequel/plugins/sharding.rb', line 41 def new_using_server(s, values={}, &block) new(values, &block).set_server(s) end |