Class: Modgen::API::Request
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#http_method ⇒ Object
readonly
Returns the value of attribute http_method.
-
#origin_url ⇒ Object
readonly
Returns the value of attribute origin_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, data = {}, http_method = :get) ⇒ Request
constructor
Create Request.
-
#response ⇒ Object
Send request.
Constructor Details
#initialize(url, data = {}, http_method = :get) ⇒ Request
Create Request
Data
path
data['path'] = {id: 1}
url = http://a.a/:id
url will be transfered to
http://a.a/1
params
normal parameters send with request
body
this will be posted to the body of request
Parameters:
- url
-
full www adress
- data
-
Hash
{ 'path' => {}, 'params' => {}, 'body' => {} } - http_method
-
http method
default: :get
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/modgen/api/request.rb', line 37 def initialize(url, data = {}, http_method = :get) @origin_url = url @url = url if data['path'] @url = url.to_s.gsub(/:([a-z][a-z0-9_]*)/) { data['path'][$1] } end @data = data @http_method = http_method.to_sym end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/modgen/api/request.rb', line 5 def data @data end |
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
5 6 7 |
# File 'lib/modgen/api/request.rb', line 5 def http_method @http_method end |
#origin_url ⇒ Object (readonly)
Returns the value of attribute origin_url.
5 6 7 |
# File 'lib/modgen/api/request.rb', line 5 def origin_url @origin_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/modgen/api/request.rb', line 5 def url @url end |
Instance Method Details
#response ⇒ Object
Send request
52 53 54 |
# File 'lib/modgen/api/request.rb', line 52 def response @response ||= _response end |