Sha256: c84a5c0ab03498670658004115c608277e1a91ea225f574db3c0e34b642c9735
Contents?: true
Size: 1.05 KB
Versions: 6
Compression:
Stored size: 1.05 KB
Contents
Mime::Type.register('application/vnd.api+json', :json_api) ActionDispatch::Request.parameter_parsers[:json_api] = lambda do |body| ActiveSupport::JSON.decode(body) end ActiveSupport.on_load(:action_controller) do ActionController::Renderers.add(:json_api) do |resources, opts| # Renderer proc is evaluated in the controller context. self.content_type ||= Mime[:json_api] ActiveSupport::Notifications.instrument('render.json_api', resources: resources, opts: opts) do if resources.is_a?(InfinumJsonApiSetup::Error::Base) break InfinumJsonApiSetup::JsonApi::ErrorSerializer.new(resources).serialized_json end break if opts[:status] == 204 serializer = opts.delete(:serializer) do "#{controller_path.classify.pluralize}::Serializer".constantize end options = InfinumJsonApiSetup::JsonApi::SerializerOptions.new( params: params.to_unsafe_h, pagination_details: opts[:pagination_details] ).build serializer.new(resources, options.merge(opts)).serializable_hash.to_json end end end
Version data entries
6 entries across 6 versions & 1 rubygems