Class: FccContentApi::Query
- Inherits:
-
Object
- Object
- FccContentApi::Query
- Defined in:
- lib/fcc-content-api.rb
Instance Method Summary collapse
- #all ⇒ Object
- #criteria ⇒ Object
- #execute ⇒ Object
-
#initialize(klass) ⇒ Query
constructor
A new instance of Query.
- #request ⇒ Object
- #where(args) ⇒ Object
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
#all ⇒ Object
35 |
# File 'lib/fcc-content-api.rb', line 35 def all; execute; end |
#criteria ⇒ Object
28 |
# File 'lib/fcc-content-api.rb', line 28 def criteria; @criteria ||= {}; end |
#execute ⇒ Object
41 42 43 44 |
# File 'lib/fcc-content-api.rb', line 41 def execute resp = request.perform.body JSON.parse(resp) end |
#request ⇒ Object
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 |