Class: Moon::Response::JSON
Overview
Moon::Response::JSON is the base class for all json responses.
Direct Known Subclasses
Defined Under Namespace
Classes: Blank, Collection, Message, Model, ValidationErrors
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(status, hash = { }) ⇒ JSON
constructor
A new instance of JSON.
Constructor Details
#initialize(status, hash = { }) ⇒ JSON
Returns a new instance of JSON.
15 16 17 |
# File 'lib/moon/response/json.rb', line 15 def initialize(status, hash = { }) @status, @hash = status, hash end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
13 14 15 |
# File 'lib/moon/response/json.rb', line 13 def hash @hash end |
#status ⇒ Object
Returns the value of attribute status.
12 13 14 |
# File 'lib/moon/response/json.rb', line 12 def status @status end |
Instance Method Details
#body ⇒ Object
23 24 25 |
# File 'lib/moon/response/json.rb', line 23 def body ::JSON.generate hash end |
#headers ⇒ Object
19 20 21 |
# File 'lib/moon/response/json.rb', line 19 def headers { "Content-Type" => "application/json" } end |