No commit activity in last 3 years
No release in over 3 years
serialize_with_coder is an ActiveRecord 2.x extended serialize function which acts like Rails 3.1 one - you can use custom coder as storing engine. Including 2 sample coders - CSV and JSON.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Serialize with Coder

serialize_with_coder is an ActiveRecord 2.x extended serialize function which acts like Rails 3.1 one - you can use custom coder as storing engine.

Including 2 sample coders:

  • CSV, SerializeWithCoder::CSVCoder
  • JSON, SerializeWithCoder::JSONCoder

Example

require 'coders/csv_coder'
require 'coders/json_coder'

class User < ActiveRecord::Base

  serialize_with_coder :newsletters, SerializeWithCoder::CSVCoder.new
  serialize_with_coder :notes,       SerializeWithCoder::JSONCoder.new

end

Example coder

class JSONCoder
  def load(data)
    JSON.parse(data) rescue nil
  end

  def dump(obj)
    obj.to_json rescue nil
  end
end

Installation

gem install serialize_with_coder

Note

Please open an issue at http://github.com/maltize/serialize_with_coder if you discover a problem.


Copyright (c) 2011 Maciej Gajek, released under the MIT license.