Sha256: 607498985c95f593af38c2f35c7873326a7546045e0238689e34844f913eb6b4
Contents?: true
Size: 969 Bytes
Versions: 2
Compression:
Stored size: 969 Bytes
Contents
require 'active_support' module Traxis module Response module JSON extend ::ActiveSupport::Concern included do attr_accessor :json_root end def initialize(json_root:nil, **args) @json_root = json_root super(**args) end def format! response_body[json_root] = @body @body = response_body @body end def handle headers['Content-Type'] = 'application/json' end def encode! @body = @body.to_json end def response_body @response_body ||= {} end end module Meta extend ::ActiveSupport::Concern def response_body super.merge!(:meta => {}) @response_body end end module Errors extend ::ActiveSupport::Concern def response_body super[:meta].merge!(:errors => []) @response_body end end end end require 'traxis/responses'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
traxis-0.0.2 | lib/traxis/response.rb |
traxis-0.0.1 | lib/traxis/response.rb |