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


54
55
56
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 54

def initialize(column)
  @column = column
end

Instance Method Details

#typeObject


66
67
68
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 66

def type
  @column.type
end

#type_cast(value) ⇒ Object


58
59
60
61
62
63
64
# File 'activerecord/lib/active_record/attribute_methods/serialization.rb', line 58

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