pboling / flag_shih_tzu

Bit fields for ActiveRecord
http://railsbling.com/flag_shih_tzu
MIT License
496 stars 64 forks source link

Query bit names on record #61

Closed wezham closed 7 years ago

wezham commented 7 years ago

Hi I was using the gem today and thought it would be nice if possible to add a functionality like:

Record.flag_names and return an array of strings containing flag names. It would be really useful to iterate over the flag names without having to hard code the names.

Not sure if the feature exists and I haven't seen it but thanks in advance :D

pboling commented 7 years ago

It is not in the README. PRs are welcome if you have time to put into documentation.

If you want to get the flag names for a single column (the gem supports multiple flag columns per table):

If you want the hash of all flag columns as keys, and names as values: ModelClass.flag_mapping

wezham commented 7 years ago

Thanks :D 👍