aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/attribute.rb')
-rw-r--r--activerecord/lib/active_record/attribute.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute.rb b/activerecord/lib/active_record/attribute.rb
index f78cde23c5..8604ccb90d 100644
--- a/activerecord/lib/active_record/attribute.rb
+++ b/activerecord/lib/active_record/attribute.rb
@@ -29,6 +29,14 @@ module ActiveRecord
type.type_cast_for_database(value)
end
+ def changed_from?(old_value)
+ type.changed?(old_value, value, value_before_type_cast)
+ end
+
+ def changed_in_place_from?(old_value)
+ type.changed_in_place?(old_value, value)
+ end
+
def type_cast
raise NotImplementedError
end
@@ -52,5 +60,16 @@ module ActiveRecord
type.type_cast_from_user(value)
end
end
+
+ class Null
+ class << self
+ attr_reader :value, :value_before_type_cast, :value_for_database
+
+ def changed_from?(*)
+ false
+ end
+ alias changed_in_place_from? changed_from?
+ end
+ end
end
end