Module: Spektrix::Base::ClassMethods

Defined in:
lib/spektrix/base.rb

Instance Method Summary collapse

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_nameString

Get the entity name; used in other places (like find())

Returns:

  • (String)

    the entity name



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

Returns:

  • (Object)

    the entity



28
29
30
# File 'lib/spektrix/base.rb', line 28

def find(id)
  where("#{entity_name}_id" => id).first
end

#firstObject



43
44
45
# File 'lib/spektrix/base.rb', line 43

def first
  all.first
end