Sha256: b50e2cb6ae677a5c2db9368fa8ffb20604e3d3289e3f76f1626ca47496f23899
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Ivy module Serializers module ActionController module SerializationSupport extend ActiveSupport::Concern class SerializerNotFound < ::StandardError end included do class_attribute :serializer, :instance_writer => false class_attribute :serialization_format, :instance_writer => false self.serialization_format = Formats::ActiveModelSerializers end private %w[ _render_option_json _render_with_renderer_json ].each do |renderer_method| define_method(renderer_method) do |resource, options| unless serializer raise SerializerNotFound, "No serializer found in #{self.class.name}" end unless resource.kind_of?(::Hash) resource = Documents.create(serializer, controller_name, resource) resource = serialization_format.new(resource) end super(resource, options) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ivy-serializers-0.1.0 | lib/ivy/serializers/action_controller/serialization_support.rb |