cerealize¶ ↑
by Cardinal Blue ( cardinalblue.com )
LINKS:¶ ↑
DESCRIPTION:¶ ↑
Serialize out of the Cerealize Box - a drop-in replacement for ActiveRecord's serialize It can auto transcode old encoding (yaml if you're using AR's serialize), to new encoding (marshal, json, you name it) without any migration. Current supported encoding: 1. YAML 2. Marshal 3. JSON (planned)
SYNOPSIS:¶ ↑
require 'cerealize' class User < ActiveRecord::Base include Cerealize # when force_encoding set to false (this is default), cerealize is # smart enough to transcode old encoding (e.g. yaml) to new encoding # (i.e. marshal) cerealize :data, Hash, :encoding => :marshal, :force_encoding => false # and this could create accessors for values store in the hash attr_hash :data, [:name, :mail] # which makes below two equivalent: # user.name = 'ham' # which is equivalent to: # user.data ||= {} # user.data[:name] = 'ham' end
REQUIREMENTS:¶ ↑
-
ActiveRecord 2 or 3
-
Tested with MRI (official ruby) 1.9.2, 1.8.7, and trunk
-
Tested with Rubinius (rbx) 1.2.3
-
Tested with JRuby 1.6.2
INSTALL:¶ ↑
> gem install cerealize # or if you want rails plugin and bleeding edge > script/plugin install git://github.com/cardinalblue/cerealize.git
LICENSE:¶ ↑
Apache License 2.0 Copyright (c) 2010-2011, Cardinal Blue Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.