Module: Ki::Model::QueryInterface
- Included in:
- Ki::Model
- Defined in:
- lib/ki/modules/query_interface.rb
Overview
the query interface does not respect before/after filters, unique attributes, required attributes or anything of the sort. it writes directly to the database
Instance Method Summary collapse
- #class_name ⇒ Object
- #count(hash = {}) ⇒ Object
- #create(hash) ⇒ Object
- #delete(hash) ⇒ Object
- #find(hash = {}) ⇒ Object
- #find_or_create(hash) ⇒ Object
- #update(hash) ⇒ Object
Instance Method Details
#class_name ⇒ Object
35 36 37 |
# File 'lib/ki/modules/query_interface.rb', line 35 def class_name to_s end |
#count(hash = {}) ⇒ Object
10 11 12 |
# File 'lib/ki/modules/query_interface.rb', line 10 def count(hash = {}) Orm::Db.instance.count class_name, hash end |
#create(hash) ⇒ Object
18 19 20 |
# File 'lib/ki/modules/query_interface.rb', line 18 def create(hash) Orm::Db.instance.insert class_name, hash end |
#delete(hash) ⇒ Object
31 32 33 |
# File 'lib/ki/modules/query_interface.rb', line 31 def delete(hash) Orm::Db.instance.delete class_name, hash end |
#find(hash = {}) ⇒ Object
14 15 16 |
# File 'lib/ki/modules/query_interface.rb', line 14 def find(hash = {}) Orm::Db.instance.find class_name, hash end |
#find_or_create(hash) ⇒ Object
22 23 24 25 |
# File 'lib/ki/modules/query_interface.rb', line 22 def find_or_create(hash) r = find hash r.empty? ? create(hash) : r end |