Class: ActiveModelSerializers::Adapter::Json

Inherits:
Base
  • Object
show all
Defined in:
lib/active_model_serializers/adapter/json.rb

Direct Known Subclasses

ActiveModel::Serializer::Adapter::Json

Instance Attribute Summary

Attributes inherited from Base

#instance_options, #serializer

Instance Method Summary collapse

Methods inherited from Base

#as_json, #cache_key, cache_key, default_key_transform, #fragment_cache, fragment_cache, inherited, #initialize, transform, transform_key_casing!

Constructor Details

This class inherits a constructor from ActiveModelSerializers::Adapter::Base

Instance Method Details

#metaObject



14
15
16
# File 'lib/active_model_serializers/adapter/json.rb', line 14

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

#meta_keyObject



18
19
20
# File 'lib/active_model_serializers/adapter/json.rb', line 18

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

#serializable_hash(options = nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/active_model_serializers/adapter/json.rb', line 6

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