aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type/binary.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/type/binary.rb')
-rw-r--r--activerecord/lib/active_record/type/binary.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/type/binary.rb b/activerecord/lib/active_record/type/binary.rb
index 3bf29b5026..005a48ef0d 100644
--- a/activerecord/lib/active_record/type/binary.rb
+++ b/activerecord/lib/active_record/type/binary.rb
@@ -22,18 +22,28 @@ module ActiveRecord
Data.new(super)
end
- class Data
+ def changed_in_place?(raw_old_value, value)
+ old_value = type_cast_from_database(raw_old_value)
+ old_value != value
+ end
+
+ class Data # :nodoc:
def initialize(value)
- @value = value
+ @value = value.to_s
end
def to_s
@value
end
+ alias_method :to_str, :to_s
def hex
@value.unpack('H*')[0]
end
+
+ def ==(other)
+ other == to_s || super
+ end
end
end
end