Module: Spektrix::Base::ClassMethods
- Defined in:
- lib/spektrix/base.rb
Instance Method Summary collapse
-
#all(args = {}) ⇒ Object
‘all’ needs to have a querystring param passed to really get all.
-
#entity_name ⇒ String
Get the entity name; used in other places (like find()).
-
#find(id) ⇒ Object
Spektrix expects the ID for an entity to be passed as a querystring parameter, as opposed to an instance being on its own url @param id [Integer] the ID you want to find.
- #first ⇒ Object
Instance Method Details
#all(args = {}) ⇒ Object
‘all’ needs to have a querystring param passed to really get all
33 34 35 |
# File 'lib/spektrix/base.rb', line 33 def all(args = {}) super({all: true}.merge(args)) end |
#entity_name ⇒ String
Get the entity name; used in other places (like find())
39 40 41 |
# File 'lib/spektrix/base.rb', line 39 def entity_name self.to_s.demodulize.underscore end |
#find(id) ⇒ Object
Spektrix expects the ID for an entity to be passed as a querystring parameter, as opposed to an instance being on its own url @param id [Integer] the ID you want to find
28 29 30 |
# File 'lib/spektrix/base.rb', line 28 def find(id) where("#{entity_name}_id" => id).first end |
#first ⇒ Object
43 44 45 |
# File 'lib/spektrix/base.rb', line 43 def first all.first end |