123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::Serialization

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Defined in: activerecord/lib/active_record/serialization.rb

::ActiveModel::Serializers::JSON - Attributes & Methods

Class Method Summary

::ActiveModel::Naming - self

param_key

Returns string to use for params names.

plural

Returns the plural class name of a record or class.

route_key

Returns string to use while generating route names.

singular

Returns the singular class name of a record or class.

singular_route_key

Returns string to use while generating route names.

uncountable?

Identifies whether the class name of a record or class is uncountable.

extended, model_name_from_record_or_class

::ActiveSupport::Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

append_features, prepend_features

Instance Method Summary

::ActiveModel::Serializers::JSON - Included

#as_json

Returns a hash representing the model.

#from_json

Sets the model attributes from a JSON string.

::ActiveModel::Serialization - Included

#read_attribute_for_serialization

Hook method defining how an attribute value should be retrieved for serialization.

#serializable_hash

Returns a serialized hash of your object.

#attribute_names_for_serialization, #serializable_attributes,
#serializable_add_includes

Add associations specified via the :include option.

DSL Calls

included

[ GitHub ]


9
10
11
# File 'activerecord/lib/active_record/serialization.rb', line 9

included do
  self.include_root_in_json = false
end

Class Attribute Details

.include_root_in_json (rw)

[ GitHub ]

  
# File 'activemodel/lib/active_model/serializers/json.rb', line 15

class_attribute :include_root_in_json, instance_writer: false, default: false

.include_root_in_json?Boolean (rw)

[ GitHub ]

  
# File 'activemodel/lib/active_model/serializers/json.rb', line 15

class_attribute :include_root_in_json, instance_writer: false, default: false

Instance Attribute Details

#include_root_in_json (readonly)

[ GitHub ]

  
# File 'activemodel/lib/active_model/serializers/json.rb', line 15

class_attribute :include_root_in_json, instance_writer: false, default: false

#include_root_in_json?Boolean (readonly)

[ GitHub ]

  
# File 'activemodel/lib/active_model/serializers/json.rb', line 15

class_attribute :include_root_in_json, instance_writer: false, default: false

Instance Method Details

#attribute_names_for_serialization (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/serialization.rb', line 25

def attribute_names_for_serialization
  attribute_names
end

#serializable_hash(options = nil)

[ GitHub ]

  
# File 'activerecord/lib/active_record/serialization.rb', line 13

def serializable_hash(options = nil)
  if self.class._has_attribute?(self.class.inheritance_column)
    options = options ? options.dup : {}

    options[:except] = Array(options[:except]).map(&:to_s)
    options[:except] |= Array(self.class.inheritance_column)
  end

  super(options)
end