Class: ActiveRecord::AttributeMethods::Serialization::Type

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/attribute_methods/serialization.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(column) ⇒ Type

Returns a new instance of Type.



73
74
75
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 73

def initialize(column)
  @column = column
end

Instance Method Details

#accessorObject



89
90
91
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 89

def accessor
  ActiveRecord::Store::IndifferentHashAccessor
end

#typeObject



85
86
87
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 85

def type
  @column.type
end

#type_cast(value) ⇒ Object



77
78
79
80
81
82
83
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 77

def type_cast(value)
  if value.state == :serialized
    value.unserialized_value @column.type_cast value.value
  else
    value.unserialized_value
  end
end