# File lib/storing/store.rb, line 38 def self.primary_key @primary_key || raise(MissingPrimaryKey, 'primary key not assigned') end
class Storing::Store
Attributes
adaptor[R]
Public Class Methods
new(adaptor)
click to toggle source
# File lib/storing/store.rb, line 52 def initialize adaptor @adaptor = adaptor end
primary_key()
click to toggle source
set_primary_key(val)
click to toggle source
# File lib/storing/store.rb, line 34 def self.set_primary_key val @primary_key = val end
set_table_name(val)
click to toggle source
# File lib/storing/store.rb, line 42 def self.set_table_name val @table_name = val end
table_name()
click to toggle source
# File lib/storing/store.rb, line 46 def self.table_name @table_name || raise(MissingTableName, 'table name not assigned') end
Public Instance Methods
delete(entity_hash={})
click to toggle source
# 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={})
click to toggle source
# File lib/storing/store.rb, line 64 def insert entity_hash={} adaptor.insert(table_name, entity_hash) end
primary_key()
click to toggle source
# File lib/storing/store.rb, line 86 def primary_key self.class.primary_key end
query(query_object)
click to toggle source
# File lib/storing/store.rb, line 56 def query query_object adaptor.query(query_object) end
select(conditions={})
click to toggle source
# File lib/storing/store.rb, line 60 def select conditions={} adaptor.select(table_name, conditions) end
table_name()
click to toggle source
# File lib/storing/store.rb, line 82 def table_name self.class.table_name end
transaction()
click to toggle source
# File lib/storing/store.rb, line 78 def transaction adaptor.transaction end
update(entity_hash={})
click to toggle source
# 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
Private Instance Methods
new_entity(entity_hash={})
click to toggle source
# File lib/storing/store.rb, line 92 def new_entity entity_hash={} ::Storing::Store::Entity.new(primary_key, entity_hash) end