Module: Traxis::Response::JSON
- Extended by:
- ActiveSupport::Concern
- Included in:
- Traxis::Responses::Collection, Traxis::Responses::Ok, Traxis::Responses::Resource, Traxis::Responses::Unauthorized
- Defined in:
- lib/traxis/response.rb
Instance Method Summary collapse
- #encode! ⇒ Object
- #format! ⇒ Object
- #handle ⇒ Object
- #initialize(json_root: nil, **args) ⇒ Object
- #response_body ⇒ Object
Instance Method Details
#encode! ⇒ Object
28 29 30 |
# File 'lib/traxis/response.rb', line 28 def encode! @body = @body.to_json end |
#format! ⇒ Object
18 19 20 21 22 |
# File 'lib/traxis/response.rb', line 18 def format! response_body[json_root] = @body @body = response_body @body end |
#handle ⇒ Object
24 25 26 |
# File 'lib/traxis/response.rb', line 24 def handle headers['Content-Type'] = 'application/json' end |
#initialize(json_root: nil, **args) ⇒ Object
12 13 14 15 16 |
# File 'lib/traxis/response.rb', line 12 def initialize(json_root:nil, **args) @json_root = json_root super(**args) end |
#response_body ⇒ Object
32 33 34 |
# File 'lib/traxis/response.rb', line 32 def response_body @response_body ||= {} end |