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.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/type/binary.rb b/activerecord/lib/active_record/type/binary.rb
index e34b7bb268..bc93f6e1bf 100644
--- a/activerecord/lib/active_record/type/binary.rb
+++ b/activerecord/lib/active_record/type/binary.rb
@@ -9,8 +9,22 @@ module ActiveRecord
true
end
- def klass
- ::String
+ def type_cast_for_database(value)
+ Data.new(super)
+ end
+
+ class Data
+ def initialize(value)
+ @value = value
+ end
+
+ def to_s
+ @value
+ end
+
+ def hex
+ @value.unpack('H*')[0]
+ end
end
end
end