Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Attribute serializer for ActiveRecord models
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
VERSION
ar_attribute_serializer.gemspec

README.md

AR Attribute Serializer

ar_attribute_serializer is a simple method that allows you to serialize random ActiveRecord Model attributes.

Installation

Define the following in your Gemfile and run bundle install

gem 'ar_attribute_serializer'

Usage

Define a field that is going to be used for storing serialized data and a list of attributes:

class MyModel < ActiveRecord::Base
  attribute_serializer :serialized_data, :apple, :orange, :banana
end

Then you can use those serialized attributes:

>> model = MyModel.new(:apple => 'red')
>> model.apple
=> red
>> model.orange = 'orange'
>> model.banana = 'yellow'
>> model.serialized_data
=> {:apple => 'red', :orange => 'orange', :banana => 'yellow' }

Copyright

(c) 2011 Oleg Khabarov, released under the MIT license

Something went wrong with that request. Please try again.