Sha256: 3a01841330a0fa427d1f2fd70dc10ee858d7b3b66092d5b520c99a0b599439b7

Contents?: true

Size: 988 Bytes

Versions: 6

Compression:

Stored size: 988 Bytes

Contents

= Metabolical

Metabolical is an ActiveRecord Model & mixin that adds metadata to your AR classes.
Whenever you feel like adding a column to a table ask yourself if what you really want is just some metadata.

== Install

  gem install metabolical

== Usage

  class User < ActiveRecord::Base
    metabolize!
  end
  
  user = User.new
  user.metas['active'] = true
  user.metas['active'].data #=> true
  
  User.with_meta('active') #=> all users with some metadata keyed as 'active'
  User.with_meta_data('active', true) #=> all user with metadata with key 'active' and set to true
  User.without_meta('asshole') #=> all users that don't have a metadata keyed as 'asshole'.
  
== Notes

Metabolical will need you to run the following migration

  create_table :meta_data, :force => true do |t|
    t.integer :metabolized_id
    t.string  :metabolized_type
    t.string  :key
    t.text    :data
    t.timestamps
  end
  
  add_index :meta_data, [:metabolized_id, :metabolized_type, :key]

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
metabolical-1.2.2 README.rdoc
metabolical-1.2.1 README.rdoc
metabolical-1.2.0 README.rdoc
metabolical-1.1.0 README.rdoc
metabolical-0.0.4 README.rdoc
metabolical-0.0.3 README.rdoc