diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-05-26 15:22:09 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-05-26 15:22:09 +0200 |
commit | d075c84320fab51992a1ab7d020c62ff1bad0b4e (patch) | |
tree | f0ed59342e74f36f34a3c3b57edcbd5c938b1c34 /activerecord/lib/active_record/attribute_methods | |
parent | 7a2b37fbbbe5ef7dd9693bc7d4b404ec7e461fff (diff) | |
parent | b5c4ef2c785ef634a81d7bb554e9b20f164be95b (diff) | |
download | rails-d075c84320fab51992a1ab7d020c62ff1bad0b4e.tar.gz rails-d075c84320fab51992a1ab7d020c62ff1bad0b4e.tar.bz2 rails-d075c84320fab51992a1ab7d020c62ff1bad0b4e.zip |
Merge pull request #15307 from sgrif/sg-type-cast-for-write
Add an interface for type objects to control Ruby => SQL
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/serialization.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb index 53a9c874bf..47c6f94ba7 100644 --- a/activerecord/lib/active_record/attribute_methods/serialization.rb +++ b/activerecord/lib/active_record/attribute_methods/serialization.rb @@ -65,6 +65,8 @@ module ActiveRecord end class Type # :nodoc: + delegate :type, :type_cast_for_database, to: :@column + def initialize(column) @column = column end @@ -77,10 +79,6 @@ module ActiveRecord end end - def type - @column.type - end - def accessor ActiveRecord::Store::IndifferentHashAccessor end diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb index dfebb2cf56..6149ac4906 100644 --- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb @@ -2,6 +2,8 @@ module ActiveRecord module AttributeMethods module TimeZoneConversion class Type # :nodoc: + delegate :type, :type_cast_for_database, to: :@column + def initialize(column) @column = column end @@ -10,10 +12,6 @@ module ActiveRecord value = @column.type_cast(value) value.acts_like?(:time) ? value.in_time_zone : value end - - def type - @column.type - end end extend ActiveSupport::Concern |