Permalink
Browse files

base64

  • Loading branch information...
1 parent d186efd commit 8a0912787b5b913d906206c7fb78ef0327ccc88b Mikhail Gulin committed Mar 14, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/record_history/record_history_model.rb
@@ -1,3 +1,5 @@
+require 'base64'
+
class RecordHistoryModel < ActiveRecord::Base
self.table_name = "record_histories"
@@ -8,11 +10,11 @@ class RecordHistoryModel < ActiveRecord::Base
def old_value
self.old_value = nil if self.old_value_dump.nil?
- self.old_value_dump.nil? ? nil : Marshal.load(self.old_value_dump)
+ self.old_value_dump.nil? ? nil : decode_value(self.old_value_dump)
end
def old_value=(value)
- self.old_value_dump = Marshal.dump(value)
+ self.old_value_dump = encode_value(value)
end
def new_value
@@ -23,4 +25,14 @@ def new_value
def new_value=(value)
self.new_value_dump = Marshal.dump(value)
end
+
+ private
+
+ def encode_value(value)
+ Base64.encode64(Marshal.dump(value))
+ end
+
+ def decode_value(value)
+ Marshal.load(Base64.decode64(value))
+ end
end

0 comments on commit 8a09127

Please sign in to comment.