module Spektrix::Base::ClassMethods

Public Instance Methods

all(args = {}) click to toggle source

'all' needs to have a querystring param passed to really get all

Calls superclass method
# File lib/spektrix/base.rb, line 33
def all(args = {})
  super({all: true}.merge(args))
end
entity_name() click to toggle source

Get the entity name; used in other places (like find()) @return [String] the entity name

# File lib/spektrix/base.rb, line 39
def entity_name
  self.to_s.demodulize.underscore
end
find(id) click to toggle source
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

@return [Object] the entity
# File lib/spektrix/base.rb, line 28
def find(id)
  where("#{entity_name}_id" => id).first
end
first() click to toggle source
# File lib/spektrix/base.rb, line 43
def first
  all.first
end