An Active Record gem to store a collection of booleans in a single column, using a postgres array field type.
Very inspired by the gem flag_shih_tzu gem.
The main puporse of using a varchar column and futher an array column, is to facilitate 3rd party SQL reporting.
Very alpha release. Never been used in production or under load yet. And it is using a varchar field to store the choices. Still working on array support.
Specs schema inspired by pg_search gem.
Defining the flags
class Product < ActiveRecord::Base include PgArray array_column :channels, [:main, :resellers, :partners] array_column :properties, [:title, :description], :prefix => 'must_have' end
Setting and Getting
product = Product.new product.main = true product.main? # true product.must_have_title = false product.must_have_title? # false
product = Product.create :title =>'T-Shirt' Product.all :conditions => Product.main_condition # [product]
Really use a array field to store the values. Currently is uses a varchar field and
Add support to array columns to active record.
Generate indexes for the array field
Contributing to pg_array
Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
Fork the project
Start a feature/bugfix branch
Commit and push until you are happy with your contribution
Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright © 2011 Marcus Derencius. See LICENSE.txt for further details.