0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
This is an ActiveRecord Model & mixin to add meta data to any AR object
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 10.0
~> 3.0

Runtime

~> 7.0, >= 7.0.0
 Project Readme

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]