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, 18 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/type/binary.rb b/activerecord/lib/active_record/type/binary.rb
index e34b7bb268..9d10c91fc1 100644
--- a/activerecord/lib/active_record/type/binary.rb
+++ b/activerecord/lib/active_record/type/binary.rb
@@ -12,6 +12,24 @@ module ActiveRecord
def klass
::String
end
+
+ 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
end