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
33 34 35 |
# File 'lib/ki/modules/query_interface.rb', line 33 def class_name to_s end |
#count(hash = {}) ⇒ Object
8 9 10 |
# File 'lib/ki/modules/query_interface.rb', line 8 def count(hash = {}) Orm::Db.instance.count class_name, hash end |
#create(hash) ⇒ Object
16 17 18 |
# File 'lib/ki/modules/query_interface.rb', line 16 def create(hash) Orm::Db.instance.insert class_name, hash end |
#delete(hash) ⇒ Object
29 30 31 |
# File 'lib/ki/modules/query_interface.rb', line 29 def delete(hash) Orm::Db.instance.delete class_name, hash end |
#find(hash = {}) ⇒ Object
12 13 14 |
# File 'lib/ki/modules/query_interface.rb', line 12 def find(hash = {}) Orm::Db.instance.find class_name, hash end |
#find_or_create(hash) ⇒ Object
20 21 22 23 |
# File 'lib/ki/modules/query_interface.rb', line 20 def find_or_create(hash) r = find hash r.empty? ? create(hash) : r end |