Class: Patronage::Service
- Inherits:
-
Object
- Object
- Patronage::Service
- Defined in:
- lib/patronage/service.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #get(params) ⇒ Object
-
#initialize(api, name, opts = {}) ⇒ Service
constructor
A new instance of Service.
- #service_location ⇒ Object
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
#name ⇒ Object (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_location ⇒ Object
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 |