0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
turns an hstore column into a very useful flags container instead of using separate columns
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.17
>= 0
~> 2.14

Runtime

 Project Readme

ABANDON NOTICE

This gem is no longer maintained. Rails Core supports HStore and JSON fields directly. You should no longer need this Gem if you are using a newer version of Rails.

HStore Flags

Gem Version License Build Status Code Climate Test Coverage

integer/bit flags aggrevating you? try this.

Requirements

Installation

TODO

Usage

# Add hstore flags column to your table in a migration
def change
  add_column :shipments, :flags, :hstore
end

# defining flags
class User < ActiveRecord::Base
  hstore_flags :active, :admin
  hstore_flags :customer, :vendor, :drop_ship, field: "user_type"
end

class Group < ActiveRecord::Base
  hstore_flags :active, :public, :invite_only, scopes: false
end

# setting flags
u = User.new
u.active = true
u.vendor = false

# automatic scope creation
User.active.to_sql        #=> SELECT * FROM users WHERE (defined(flags, 'active') IS TRUE)
User.not_drop_ship.to_sql #=> SELECT * FROM users WHERE (defined(user_type, 'drop_ship') IS NOT TRUE)
  • field option defaults to flags
  • scopes: false disables scope creation. though im not sure how useful that is

Contributors