Module: Sequel::Plugins::Sharding::DatasetMethods

Defined in:
lib/sequel/plugins/sharding.rb

Instance Method Summary collapse

Instance Method Details

#server(s) ⇒ Object

If a row proc exists on the dataset, replace it with one that calls the previous row_proc, but calls set_server on the output of that row_proc, ensuring that objects retrieved by a specific shard know which shard they are tied to.



107
108
109
110
111
112
113
# File 'lib/sequel/plugins/sharding.rb', line 107

def server(s)
  ds = super
  if rp = row_proc
    ds.row_proc = proc{|r| rp.call(r).set_server(s)}
  end
  ds
end