Class: Kibosh::Response
- Inherits:
-
Object
- Object
- Kibosh::Response
- Includes:
- Mixin
- Defined in:
- lib/kibosh/response.rb
Defined Under Namespace
Modules: Mixin
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#defer_fired ⇒ Object
Returns the value of attribute defer_fired.
-
#deferred ⇒ Object
Returns the value of attribute deferred.
-
#deliver_fired ⇒ Object
Returns the value of attribute deliver_fired.
-
#delivered ⇒ Object
Returns the value of attribute delivered.
-
#session ⇒ Object
Returns the value of attribute session.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #_cancel! ⇒ Object
- #_deliver ⇒ Object
- #defer ⇒ Object
-
#initialize(async_callback, close_callback) ⇒ Response
constructor
A new instance of Response.
- #on_close(&block) ⇒ Object
Methods included from Mixin
#body, #body=, #headers, #rack, #status, #status=, #xml
Constructor Details
#initialize(async_callback, close_callback) ⇒ Response
Returns a new instance of Response.
79 80 81 82 83 84 85 86 |
# File 'lib/kibosh/response.rb', line 79 def initialize async_callback, close_callback raise "hell" if !Method === async_callback @callback = async_callback @closed = close_callback @callback.receiver.comm_inactivity_timeout = 0 @fired = @deferred = false @created_at = Time.now end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
88 89 90 |
# File 'lib/kibosh/response.rb', line 88 def created_at @created_at end |
#defer_fired ⇒ Object
Returns the value of attribute defer_fired.
89 90 91 |
# File 'lib/kibosh/response.rb', line 89 def defer_fired @defer_fired end |
#deferred ⇒ Object
Returns the value of attribute deferred.
89 90 91 |
# File 'lib/kibosh/response.rb', line 89 def deferred @deferred end |
#deliver_fired ⇒ Object
Returns the value of attribute deliver_fired.
89 90 91 |
# File 'lib/kibosh/response.rb', line 89 def deliver_fired @deliver_fired end |
#delivered ⇒ Object
Returns the value of attribute delivered.
89 90 91 |
# File 'lib/kibosh/response.rb', line 89 def delivered @delivered end |
#session ⇒ Object
Returns the value of attribute session.
68 69 70 |
# File 'lib/kibosh/response.rb', line 68 def session @session end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
68 69 70 |
# File 'lib/kibosh/response.rb', line 68 def stream @stream end |
Instance Method Details
#_cancel! ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/kibosh/response.rb', line 102 def _cancel! raise "hell" if delivered || !deferred self.deferred = false @callback.call nil self.delivered = true @closed = nil @callback = nil end |
#_deliver ⇒ Object
111 112 113 114 115 116 |
# File 'lib/kibosh/response.rb', line 111 def _deliver raise "hell" if delivered || !deferred @closed.cancel_callback @close_block self.deferred = false @callback.call rack end |
#defer ⇒ Object
91 92 93 94 95 96 |
# File 'lib/kibosh/response.rb', line 91 def defer body = @body @body = nil @session.defer self body end |
#on_close(&block) ⇒ Object
98 99 100 |
# File 'lib/kibosh/response.rb', line 98 def on_close &block @closed.callback &(@close_block = block) end |