module Sequel::SchemaSharding::ShardedModel
Public Class Methods
included(base)
click to toggle source
# File lib/sequel/schema-sharding/model.rb, line 29 def self.included(base) base.extend(ClassMethods) base.plugin(:dataset_shard_id) end
Public Instance Methods
_insert_dataset()
click to toggle source
Overriden to not use @dataset value from the Sequel::Model. Used internally only.
# File lib/sequel/schema-sharding/model.rb, line 108 def _insert_dataset this_server end
db()
click to toggle source
The database connection that has the logical shard.
# File lib/sequel/schema-sharding/model.rb, line 93 def db @db ||= finder_result.connection end
finder_result()
click to toggle source
Wrapper for performing the sharding lookup based on the sharded column.
# File lib/sequel/schema-sharding/model.rb, line 98 def finder_result @result ||= self.class.result_for(self.send(self.class.sharded_column)) end
this_server()
click to toggle source
Dataset instance based on the sharded column.
# File lib/sequel/schema-sharding/model.rb, line 103 def this_server @this_server ||= db[self.class.schema_and_table(finder_result)] end