Class: FccContentApi::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/fcc-content-api.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Query

Returns a new instance of Query.



26
# File 'lib/fcc-content-api.rb', line 26

def initialize(klass); @klass = klass; end

Instance Method Details

#allObject



35
# File 'lib/fcc-content-api.rb', line 35

def all; execute; end

#criteriaObject



28
# File 'lib/fcc-content-api.rb', line 28

def criteria; @criteria ||= {}; end

#executeObject



41
42
43
44
# File 'lib/fcc-content-api.rb', line 41

def execute
  resp = request.perform.body
  JSON.parse(resp)
end

#requestObject



37
38
39
# File 'lib/fcc-content-api.rb', line 37

def request
  @request ||= FccContentApi.client.all criteria
end

#where(args) ⇒ Object



30
31
32
33
# File 'lib/fcc-content-api.rb', line 30

def where(args)
  criteria.merge! args
  self
end