Sha256: e332ed231eaec6ce50097a70b59a88c9af6a68a87330882f72f0cfe321e86c5d

Contents?: true

Size: 623 Bytes

Versions: 8

Compression:

Stored size: 623 Bytes

Contents

# frozen_string_literal: true

module ActiveModelSerializers
  module Adapter
    class Json < Base
      def serializable_hash(options = nil)
        options = serialization_options(options)
        serialized_hash = { root => Attributes.new(serializer, instance_options).serializable_hash(options) }
        serialized_hash[meta_key] = meta unless meta.blank?

        self.class.transform_key_casing!(serialized_hash, instance_options)
      end

      def meta
        instance_options.fetch(:meta, nil)
      end

      def meta_key
        instance_options.fetch(:meta_key, 'meta'.freeze)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
active_model_serializers-0.10.15 lib/active_model_serializers/adapter/json.rb
active_model_serializers-0.10.14 lib/active_model_serializers/adapter/json.rb
active_model_serializers-0.10.13 lib/active_model_serializers/adapter/json.rb
active_model_serializers-0.10.12 lib/active_model_serializers/adapter/json.rb
active_model_serializers-0.10.11 lib/active_model_serializers/adapter/json.rb
active_model_serializers-0.10.10 lib/active_model_serializers/adapter/json.rb
active_model_serializers_custom-0.10.90 lib/active_model_serializers/adapter/json.rb
active_model_serializers-0.10.9 lib/active_model_serializers/adapter/json.rb