Project

tm-flagged

0.0
No commit activity in last 3 years
No release in over 3 years
Do not create more boolean fields :)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

tm-flagged¶ ↑

Original idea by github.com/xing/flag_shin_tzu

warning:

NOT FOR PRODUCTION USE NOW

Installation¶ ↑

gem install tm-flagged

Usage¶ ↑

ActiveRecord¶ ↑

You have to add one field to your model, eg. named flags

add_column :transactions, :flags, :integer, :default => 0

DataMapper¶ ↑

just add new property

property :flags, Integer, :default => 0

In model¶ ↑

just add this has_flags to your model to define flags

has_flags 1 => :sun,
          2 => :clouds,
          3 => :rain,
          4 => :frogs,
          5 => :ufo

Then you could use autogenerated methods like

model.sun?   # => true/false
model.sun=true
model.sun    # => true/false

If you want to use another column than flags, use :column option

property :weather, Integer, :default => 0

has_flags 1 => :sun,
          2 => :clouds,
          :column => :weather

model.clouds?

License¶ ↑

Copyright © 2010 Tom Meinlschmidt, see LICENSE file