Module: QueryInterface::Client::Resource::ClassMethods
- Defined in:
- lib/query-interface-client/resource.rb
Instance Method Summary collapse
- #[](id) ⇒ Object
- #all ⇒ Object
- #association(name, options = {}) ⇒ Object
- #first(*args) ⇒ Object
- #last(*args) ⇒ Object
- #query ⇒ Object
Instance Method Details
#[](id) ⇒ Object
46 47 48 |
# File 'lib/query-interface-client/resource.rb', line 46 def [](id) self.query.instance(id).evaluate end |
#all ⇒ Object
50 51 52 |
# File 'lib/query-interface-client/resource.rb', line 50 def all self.query.evaluate end |
#association(name, options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/query-interface-client/resource.rb', line 38 def association(name, ={}) association = QueryInterface::Client::Association.new(self, name, ) define_method name do association.query(self.id) end @associations[name] = association end |
#first(*args) ⇒ Object
26 27 28 |
# File 'lib/query-interface-client/resource.rb', line 26 def first(*args) self.query.order('id').first end |
#last(*args) ⇒ Object
30 31 32 |
# File 'lib/query-interface-client/resource.rb', line 30 def last(*args) self.query.order('id').last end |