Class: Alice::Response
- Extended by:
- AutoloadHelper
- Defined in:
- lib/alice/response.rb
Defined Under Namespace
Classes: ActiveSupportJson, Middleware, Yajl
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #finish(env) ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #on_complete(&block) ⇒ Object
Methods included from AutoloadHelper
all_loaded_constants, autoload_all, load_autoloaded_constants, lookup_module, register_lookup_modules
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
33 34 35 36 |
# File 'lib/alice/response.rb', line 33 def initialize @status, @headers, @body = nil, nil, nil @on_complete_callbacks = [] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
31 32 33 |
# File 'lib/alice/response.rb', line 31 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
31 32 33 |
# File 'lib/alice/response.rb', line 31 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
31 32 33 |
# File 'lib/alice/response.rb', line 31 def status @status end |
Instance Method Details
#finish(env) ⇒ Object
42 43 44 45 46 |
# File 'lib/alice/response.rb', line 42 def finish(env) @on_complete_callbacks.each { |c| c.call(env) } @status, @headers, @body = env[:status], env[:response_headers], env[:body] self end |
#on_complete(&block) ⇒ Object
38 39 40 |
# File 'lib/alice/response.rb', line 38 def on_complete(&block) @on_complete_callbacks << block end |