Class: Copy::Request::Info
- Inherits:
-
Object
- Object
- Copy::Request::Info
- Defined in:
- lib/copy/request/info.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#base_path ⇒ Object
Returns the value of attribute base_path.
-
#data ⇒ Object
Returns the value of attribute data.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#session ⇒ Object
Returns the value of attribute session.
-
#subdomain ⇒ Object
Returns the value of attribute subdomain.
Instance Method Summary collapse
-
#initialize(http_method, subdomain, api_url, data, options = {}) ⇒ Info
constructor
A new instance of Info.
- #path_with_params(path, params) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(http_method, subdomain, api_url, data, options = {}) ⇒ Info
Returns a new instance of Info.
6 7 8 9 10 11 12 13 |
# File 'lib/copy/request/info.rb', line 6 def initialize(http_method, subdomain, api_url, data, ={}) @http_method = http_method @subdomain = subdomain || DOMAIN_BASE @api_url = api_url @data = data @base_path = API_BASE_PATH @session = [:session] end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
4 5 6 |
# File 'lib/copy/request/info.rb', line 4 def api_url @api_url end |
#base_path ⇒ Object
Returns the value of attribute base_path.
4 5 6 |
# File 'lib/copy/request/info.rb', line 4 def base_path @base_path end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/copy/request/info.rb', line 4 def data @data end |
#http_method ⇒ Object
Returns the value of attribute http_method.
4 5 6 |
# File 'lib/copy/request/info.rb', line 4 def http_method @http_method end |
#session ⇒ Object
Returns the value of attribute session.
4 5 6 |
# File 'lib/copy/request/info.rb', line 4 def session @session end |
#subdomain ⇒ Object
Returns the value of attribute subdomain.
4 5 6 |
# File 'lib/copy/request/info.rb', line 4 def subdomain @subdomain end |
Instance Method Details
#path_with_params(path, params) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/copy/request/info.rb', line 25 def path_with_params(path, params) unless params.empty? encoded_params = URI.encode_www_form(params) [path, encoded_params].join("?") else path end end |
#url ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/copy/request/info.rb', line 15 def url url = "/#{base_path}/#{api_url}" if has_id? url += "/#{data[:id]}" data.delete(:id) end url end |