Class: Patronage::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/patronage/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, name, opts = {}) ⇒ Service

Returns a new instance of Service.



5
6
7
8
9
# File 'lib/patronage/service.rb', line 5

def initialize(api, name, opts = {})
  @api  = api
  @name = name.to_s
  @opts = opts
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/patronage/service.rb', line 3

def name
  @name
end

Instance Method Details

#get(params) ⇒ Object



17
18
19
20
21
# File 'lib/patronage/service.rb', line 17

def get(params)
  uri              = Addressable::URI.parse(service_location)
  uri.query_values = params      
  Response.new(@api.get(uri.to_s))
end

#service_locationObject



11
12
13
14
15
# File 'lib/patronage/service.rb', line 11

def service_location
  location = "/#{name}"
  location << ".#{@opts[:format]}" if @opts[:format]
  location
end