Sha256: 057dde969966b4f6ccd0190ee4faa370eb2088fa04fd6a4d2a13e4fa5556c0d5

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

module FunWithJsonApi
  module ActionControllerExtensions
    module Serialization
      # Overrides the dynamic render json_api methods to use ActiveModelSerializer
      [:_render_option_json_api, :_render_with_renderer_json_api].each do |renderer_method|
        define_method renderer_method do |resource, options|
          options.fetch(:adapter) { options[:adapter] ||= :json_api }
          options.fetch(:serialization_context) do
            options[:serialization_context] ||=
              ::ActiveModelSerializers::SerializationContext.new(request)
          end
          serializable_resource = get_serializer(resource, options)
          super(serializable_resource, options)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fun_with_json_api-0.0.14 lib/fun_with_json_api/action_controller_extensions/serialization.rb
fun_with_json_api-0.0.13 lib/fun_with_json_api/action_controller_extensions/serialization.rb
fun_with_json_api-0.0.11.3 lib/fun_with_json_api/action_controller_extensions/serialization.rb
fun_with_json_api-0.0.11.2 lib/fun_with_json_api/action_controller_extensions/serialization.rb