Class: Restulicious::QueryInterface
- Inherits:
-
Object
- Object
- Restulicious::QueryInterface
- Defined in:
- lib/restulicious/query_interface.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #all_url ⇒ Object
- #first_url ⇒ Object
- #from(url) ⇒ Object
-
#initialize(url) ⇒ QueryInterface
constructor
A new instance of QueryInterface.
- #limit(limit) ⇒ Object
- #offset(offset) ⇒ Object
- #select(fields) ⇒ Object
- #where(params) ⇒ Object
Constructor Details
#initialize(url) ⇒ QueryInterface
Returns a new instance of QueryInterface.
6 7 8 9 |
# File 'lib/restulicious/query_interface.rb', line 6 def initialize(url) @url = url @params = {} end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/restulicious/query_interface.rb', line 4 def params @params end |
Instance Method Details
#all_url ⇒ Object
36 37 38 |
# File 'lib/restulicious/query_interface.rb', line 36 def all_url interpolated_url end |
#first_url ⇒ Object
40 41 42 |
# File 'lib/restulicious/query_interface.rb', line 40 def first_url [interpolated_url, @params[:id]].compact.join("/") end |
#from(url) ⇒ Object
16 17 18 19 |
# File 'lib/restulicious/query_interface.rb', line 16 def from(url) @url = url self end |
#limit(limit) ⇒ Object
21 22 23 24 |
# File 'lib/restulicious/query_interface.rb', line 21 def limit(limit) @params[:limit] = limit self end |
#offset(offset) ⇒ Object
26 27 28 29 |
# File 'lib/restulicious/query_interface.rb', line 26 def offset(offset) @params[:offset] = offset self end |
#select(fields) ⇒ Object
31 32 33 34 |
# File 'lib/restulicious/query_interface.rb', line 31 def select(fields) @params[:fields] = fields self end |
#where(params) ⇒ Object
11 12 13 14 |
# File 'lib/restulicious/query_interface.rb', line 11 def where(params) @params.merge!(params) self end |