Module: Ethon::Easy::Http::Actionable
- Defined in:
- lib/ethon/easy/http/actionable.rb
Overview
This module represents a Http Action and is a factory for more real actions like GET, HEAD, POST and PUT.
Instance Method Summary collapse
-
#form ⇒ Form
Return the form.
-
#initialize(url, options) ⇒ Action
Create a new action.
-
#options ⇒ Hash
Return the options hash.
-
#params ⇒ Params
Return the params.
-
#set_form(easy) ⇒ Object
Setup request with form.
-
#set_params(easy) ⇒ Object
Setup request with params.
-
#setup(easy) ⇒ Object
Setup everything necessary for a proper request.
-
#url ⇒ String
Return the url.
Instance Method Details
#form ⇒ Form
Return the form.
61 62 63 |
# File 'lib/ethon/easy/http/actionable.rb', line 61 def form @form ||= Form.new(@easy, .delete(:body)) end |
#initialize(url, options) ⇒ Action
Create a new action.
20 21 22 23 |
# File 'lib/ethon/easy/http/actionable.rb', line 20 def initialize(url, ) @url = url @options = .dup end |
#options ⇒ Hash
Return the options hash.
41 42 43 |
# File 'lib/ethon/easy/http/actionable.rb', line 41 def @options end |
#params ⇒ Params
Return the params.
51 52 53 |
# File 'lib/ethon/easy/http/actionable.rb', line 51 def params @params ||= Params.new(@easy, .delete(:params)) end |
#set_form(easy) ⇒ Object
Setup request with form.
99 100 |
# File 'lib/ethon/easy/http/actionable.rb', line 99 def set_form(easy) end |
#set_params(easy) ⇒ Object
Setup request with params.
88 89 90 91 |
# File 'lib/ethon/easy/http/actionable.rb', line 88 def set_params(easy) params.escape = true easy.url = "#{url}?#{params.to_s}" end |
#setup(easy) ⇒ Object
Setup everything necessary for a proper request.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ethon/easy/http/actionable.rb', line 71 def setup(easy) @easy = easy if params.empty? easy.url = url else set_params(easy) end set_form(easy) unless form.empty? easy.set_attributes() end |
#url ⇒ String
Return the url.
31 32 33 |
# File 'lib/ethon/easy/http/actionable.rb', line 31 def url @url end |