Class: Restulicious::QueryInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/restulicious/query_interface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paramsObject (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_urlObject



36
37
38
# File 'lib/restulicious/query_interface.rb', line 36

def all_url
  interpolated_url
end

#first_urlObject



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