0.01
No commit activity in last 3 years
No release in over 3 years
Outputs keys used in the FlagShihTzu setup. Can be filtered by column for models with multiple flag columns.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.6.4
>= 0
 Project Readme

awesome_flags

You'll need the FlagShihTzu plugin installed.

plugin install git://github.com/xing/flag_shih_tzu.git

Then set that up how you like. FlagShihTzu

Then get the awesome_flags gem.

gem 'awesome_flags'

AwesomeFlags outputs the keys used in FlagShihTzu columns as an Array of :symbols, or a Hash of flag names and bit values.

Just require AwesomeFlags in your model. Don't forget to install the FlagShihTzu plugin and add that as well.

include FlagShihTzu
include AwesomeFlags

Array Methods

Call all active flags for a variable, or add a column name to filter.

my_flags    
my_flags("column_name")

Using the all_flags method will return all flags (filtered by column or not).

all_flags
all_flags("column_name")

You can also send either method to a block to output formatted flags.
This can be handy to do things like generate check boxes dynamically. For example

- @thing.all_flags.each do |flag|
  = check_box flag, :class => 'check_box'
  = label :flags, "#{flag.to_s.titleize}"

Hash Method

There is also a method to return the hash of flag names and bit values. The keys are the flag names and the values are the bit values. This can also be filtered by column.

get_hash_of_flags
get_hash_of_flags("column_name")

Good for creating drop downs

= select(:flags, @thing.get_hash_of_flags.collect {|key, value| ["#{key.to_s.titleize}", value]})

Copyright (c) 2011 Gabe Kessler. See LICENSE.txt for further details.