Class: Frenchy::Request
- Inherits:
-
Object
- Object
- Frenchy::Request
- Defined in:
- lib/frenchy/request.rb
Instance Attribute Summary collapse
-
#extras ⇒ Object
Returns the value of attribute extras.
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#service ⇒ Object
Returns the value of attribute service.
Instance Method Summary collapse
-
#initialize(service, method, path, params = {}, extras = {}) ⇒ Request
constructor
Create a new request with given parameters.
-
#value ⇒ Object
Issue the request and return the value.
-
#value_without_instrumentation ⇒ Object
Issue the request and return the value.
Constructor Details
#initialize(service, method, path, params = {}, extras = {}) ⇒ Request
Create a new request with given parameters
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/frenchy/request.rb', line 11 def initialize(service, method, path, params={}, extras={}) path = path.dup path.scan(/(:[a-z0-9_+]+)/).flatten.uniq.each do |pat| k = pat.sub(":", "") begin v = params.fetch(pat.sub(":", "")).to_s rescue raise Frenchy::Error, "The required parameter '#{k}' was not specified." end params.delete(k) path.sub!(pat, CGI.escape(v)) end @service = service @method = method @path = path @params = params @extras = extras end |
Instance Attribute Details
#extras ⇒ Object
Returns the value of attribute extras.
8 9 10 |
# File 'lib/frenchy/request.rb', line 8 def extras @extras end |
#method ⇒ Object
Returns the value of attribute method.
8 9 10 |
# File 'lib/frenchy/request.rb', line 8 def method @method end |
#params ⇒ Object
Returns the value of attribute params.
8 9 10 |
# File 'lib/frenchy/request.rb', line 8 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/frenchy/request.rb', line 8 def path @path end |
#service ⇒ Object
Returns the value of attribute service.
8 9 10 |
# File 'lib/frenchy/request.rb', line 8 def service @service end |
Instance Method Details
#value ⇒ Object
Issue the request and return the value
33 34 35 |
# File 'lib/frenchy/request.rb', line 33 def value Frenchy.find_service(@service).send(@method, @path, @params) end |
#value_without_instrumentation ⇒ Object
Issue the request and return the value
39 40 41 |
# File 'lib/frenchy/request.rb', line 39 def value Frenchy.find_service(@service).send(@method, @path, @params) end |