Agile Web Development

Build it. Launch it. Love it.

typed_serialize

Typed serialize makes sure your serialized attribute is always the specified type. This is especially nice for serialized hashes and new models.

Example

  class User < ActiveRecord::Base
    typed_serialize :settings, Hash
  end

  User.new.settings        # => {}

  u = User.new
  u.settings[:theme] = 1
  u.settings               # => { :theme => 1 }

Install

As a Rails plugin:

  ./script/plugin install git://github.com/jqr/typed_serialize.git

Prefer gems? Add this to your environment.rb and run the following command.

  config.gem 'jqr-typed_serialize', :lib => 'typed_serialize', :source => 'http://gems.github.com'

  $ rake gems:install
Homepage:http://github.com/jqr/typed_serialize
License:Copyright © 2008 Elijah Miller <mailto:elijah.miller@gmail.com>, released under the MIT license

Vitals

Home http://github.com/jqr/typed_serialize
Repository git://github.com/jqr/typed_serialize.git
License Rails' (MIT)
Tags Tag_red
Rating (1 vote)
Owner Elijah Miller
Created 17 January 2009

Comments

Add a comment