This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 19f7c9b6b077752c2e33f4528b03b2ac0c666d9a
tree 8a2da17844f9921ba5e6f0ff5625681d60a0a107
parent a7ce536d5f326dd5ca713c65acb05cd4e193fc56
tree 8a2da17844f9921ba5e6f0ff5625681d60a0a107
parent a7ce536d5f326dd5ca713c65acb05cd4e193fc56
| name | age | message | |
|---|---|---|---|
| |
LICENSE | Sat May 16 17:23:33 -0700 2009 | |
| |
README.textile | Mon May 18 11:06:47 -0700 2009 | |
| |
init.rb | Thu Nov 19 15:41:49 -0800 2009 | |
| |
lib/ | Fri Nov 20 21:17:00 -0800 2009 | |
| |
test/ | Fri Nov 20 21:17:00 -0800 2009 |
README.textile
SerializedAttributes
SerializedAttributes allows you to add an encoded hash to an ActiveRecord model.
This is similar to the built-in ActiveRecord serialization, except that the field
is converted to JSON, gzipped, and stored in a BLOB field. This uses the json
gem which is much faster than YAML serialization. However, JSON is not nearly as
flexible, so you’re stuck with strings/integers/dates/etc.
Where possible, ActiveRecord compatible methods are generated so that a migration
should be pretty simple. See unit tests for examples.
Some of the code and most of the ideas are taken from Heresy,
a ruby implementation of how FriendFeed uses MySQL for schema-free storage.
Setup
Install the plugin into your Rails app.
Usage
class Profile < ActiveRecord::Base
# assumes #data serializes to raw_data blob field
serialize_attributes do
string :title, :description
integer :age
float :rank, :percentage
time :birthday
end
# Serializes #data to assumed raw_data blob field
serialize_attributes :data do
string :title, :description
integer :age
float :rank, :percentage
time :birthday
end
# set the blob field
serialize_attributes :data, :blob => :serialized_field do
string :title, :description
integer :age
float :rank, :percentage
time :birthday
end
end







