Skip to content

tmeinlschmidt/tm-flagged

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published