Class: Storing::Store
- Inherits:
-
AbstractStore
- Object
- AbstractStore
- Storing::Store
- Defined in:
- lib/storing/store.rb
Defined Under Namespace
Classes: Entity
Instance Attribute Summary collapse
-
#adaptor ⇒ Object
readonly
Returns the value of attribute adaptor.
Class Method Summary collapse
- .primary_key ⇒ Object
- .set_primary_key(val) ⇒ Object
- .set_table_name(val) ⇒ Object
- .table_name ⇒ Object
Instance Method Summary collapse
- #delete(entity_hash = {}) ⇒ Object
-
#initialize(adaptor) ⇒ Store
constructor
A new instance of Store.
- #insert(entity_hash = {}) ⇒ Object
- #primary_key ⇒ Object
- #query(query_object) ⇒ Object
- #select(conditions = {}) ⇒ Object
- #table_name ⇒ Object
- #transaction ⇒ Object
- #update(entity_hash = {}) ⇒ Object
Constructor Details
#initialize(adaptor) ⇒ Store
Returns a new instance of Store.
52 53 54 |
# File 'lib/storing/store.rb', line 52 def initialize adaptor @adaptor = adaptor end |
Instance Attribute Details
#adaptor ⇒ Object (readonly)
Returns the value of attribute adaptor.
50 51 52 |
# File 'lib/storing/store.rb', line 50 def adaptor @adaptor end |
Class Method Details
.primary_key ⇒ Object
38 39 40 |
# File 'lib/storing/store.rb', line 38 def self.primary_key @primary_key || raise(MissingPrimaryKey, 'primary key not assigned') end |
.set_primary_key(val) ⇒ Object
34 35 36 |
# File 'lib/storing/store.rb', line 34 def self.set_primary_key val @primary_key = val end |
.set_table_name(val) ⇒ Object
42 43 44 |
# File 'lib/storing/store.rb', line 42 def self.set_table_name val @table_name = val end |
.table_name ⇒ Object
46 47 48 |
# File 'lib/storing/store.rb', line 46 def self.table_name @table_name || raise(MissingTableName, 'table name not assigned') end |
Instance Method Details
#delete(entity_hash = {}) ⇒ Object
73 74 75 76 |
# File 'lib/storing/store.rb', line 73 def delete entity_hash={} entity = new_entity(entity_hash) adaptor.delete(table_name, entity.primary_key_hash) end |
#insert(entity_hash = {}) ⇒ Object
64 65 66 |
# File 'lib/storing/store.rb', line 64 def insert entity_hash={} adaptor.insert(table_name, entity_hash) end |
#primary_key ⇒ Object
86 87 88 |
# File 'lib/storing/store.rb', line 86 def primary_key self.class.primary_key end |
#query(query_object) ⇒ Object
56 57 58 |
# File 'lib/storing/store.rb', line 56 def query query_object adaptor.query(query_object) end |
#select(conditions = {}) ⇒ Object
60 61 62 |
# File 'lib/storing/store.rb', line 60 def select conditions={} adaptor.select(table_name, conditions) end |
#table_name ⇒ Object
82 83 84 |
# File 'lib/storing/store.rb', line 82 def table_name self.class.table_name end |
#transaction ⇒ Object
78 79 80 |
# File 'lib/storing/store.rb', line 78 def transaction adaptor.transaction end |
#update(entity_hash = {}) ⇒ Object
68 69 70 71 |
# File 'lib/storing/store.rb', line 68 def update entity_hash={} entity = new_entity(entity_hash) adaptor.update(table_name, entity.params, entity.primary_key_hash) end |