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]