Class: RespondWith::Response
- Inherits:
-
Object
- Object
- RespondWith::Response
- Defined in:
- lib/respond_with/response.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Response
constructor
A new instance of Response.
- #render ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 |
# File 'lib/respond_with/response.rb', line 8 def initialize(opts={}) @app = opts[:app] @params = opts[:params] @object = opts[:object] @request = opts[:request] @options = opts[:options] end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
3 4 5 |
# File 'lib/respond_with/response.rb', line 3 def app @app end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
5 6 7 |
# File 'lib/respond_with/response.rb', line 5 def object @object end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/respond_with/response.rb', line 4 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/respond_with/response.rb', line 6 def request @request end |
Instance Method Details
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/respond_with/response.rb', line 16 def render response_type = Negotiator.pick(request_types.join(", "), available_responses) if response_type.nil? @app.halt 406 else @app.status(@options[:status]) if @options[:status] @app.content_type(response_type) @object.to(response_type) end end |