Module: Sequel::SchemaSharding::ShardedModel
- Defined in:
- lib/sequel/schema-sharding/model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#_insert_dataset ⇒ Object
Overriden to not use @dataset value from the Sequel::Model.
-
#db ⇒ Object
The database connection that has the logical shard.
-
#finder_result ⇒ Object
Wrapper for performing the sharding lookup based on the sharded column.
-
#this_server ⇒ Object
Dataset instance based on the sharded column.
Class Method Details
.included(base) ⇒ Object
29 30 31 32 |
# File 'lib/sequel/schema-sharding/model.rb', line 29 def self.included(base) base.extend(ClassMethods) base.plugin(:dataset_shard_id) end |
Instance Method Details
#_insert_dataset ⇒ Object
Overriden to not use @dataset value from the Sequel::Model. Used internally only.
108 109 110 |
# File 'lib/sequel/schema-sharding/model.rb', line 108 def _insert_dataset this_server end |
#db ⇒ Object
The database connection that has the logical shard.
93 94 95 |
# File 'lib/sequel/schema-sharding/model.rb', line 93 def db @db ||= finder_result.connection end |
#finder_result ⇒ Object
Wrapper for performing the sharding lookup based on the sharded column.
98 99 100 |
# 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 ⇒ Object
Dataset instance based on the sharded column.
103 104 105 |
# File 'lib/sequel/schema-sharding/model.rb', line 103 def this_server @this_server ||= db[self.class.schema_and_table(finder_result)] end |