Module: Impresser::SerializationHelper

Included in:
ActiveRecord::CommentMeta, ActiveRecord::Option, ActiveRecord::PostMeta, ActiveRecord::UserMeta
Defined in:
lib/impresser/mixin/serialization_helper.rb

Instance Method Summary collapse

Instance Method Details

#php_serializable(*column_names) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/impresser/mixin/serialization_helper.rb', line 5

def php_serializable(*column_names)
  column_names.each do |column_name|
    define_method(column_name) do
      value = read_attribute(column_name)
      if value.to_s.match(/^[abdiorsCONRU]:\d+:/)
        PHP.unserialize(value.to_s)
      else
        value
      end
    end
  end
end