Class: UnderOs::HTTP::Request
- Inherits:
-
Object
- Object
- UnderOs::HTTP::Request
- Includes:
- Events
- Defined in:
- lib/under_os/http/request.rb,
lib/under_os/http/receiver.rb
Overview
A little wrap to handle iOS HTTP requests receiving
Defined Under Namespace
Classes: Receiver
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #cancel ⇒ Object
- #cookies ⇒ Object
- #headers ⇒ Object
-
#initialize(url, options = {}, &block) ⇒ Request
constructor
A new instance of Request.
- #on(*args, &block) ⇒ Object
- #send ⇒ Object
Methods included from Events
Constructor Details
#initialize(url, options = {}, &block) ⇒ Request
Returns a new instance of Request.
21 22 23 24 25 26 |
# File 'lib/under_os/http/request.rb', line 21 def initialize(url, ={}, &block) @url = url @options = on :complete, &block if block_given? end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
19 20 21 |
# File 'lib/under_os/http/request.rb', line 19 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
19 20 21 |
# File 'lib/under_os/http/request.rb', line 19 def params @params end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
19 20 21 |
# File 'lib/under_os/http/request.rb', line 19 def url @url end |
Instance Method Details
#cancel ⇒ Object
42 43 44 |
# File 'lib/under_os/http/request.rb', line 42 def cancel @connection.cancel end |
#cookies ⇒ Object
57 58 59 |
# File 'lib/under_os/http/request.rb', line 57 def @options[:cookies] || {} end |
#headers ⇒ Object
53 54 55 |
# File 'lib/under_os/http/request.rb', line 53 def headers @options[:headers] || {} end |
#on(*args, &block) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/under_os/http/request.rb', line 28 def on(*args, &block) super *args do |event| args = block.arity == 0 ? [] : [event.params[:response]] block.call *args end end |