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 |
# File 'lib/sequel/schema-sharding/model.rb', line 29 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#_insert_dataset ⇒ Object
Overriden to not use @dataset value from the Sequel::Model. Used internally only.
86 87 88 |
# File 'lib/sequel/schema-sharding/model.rb', line 86 def _insert_dataset this_server end |
#db ⇒ Object
The database connection that has the logical shard.
71 72 73 |
# File 'lib/sequel/schema-sharding/model.rb', line 71 def db @db ||= finder_result.connection end |
#finder_result ⇒ Object
Wrapper for performing the sharding lookup based on the sharded column.
76 77 78 |
# File 'lib/sequel/schema-sharding/model.rb', line 76 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.
81 82 83 |
# File 'lib/sequel/schema-sharding/model.rb', line 81 def this_server @this_server ||= db[self.class.schema_and_table(finder_result)] end |