Flagger 0.9.0 released

I’ve just released a Rails plugin that simplifies dealing with boolean flags in ActiveRecord. It gives you a load of easy-to-read dynamic attribute-based finders and setter methods without you having to write a line of code. It’s perfect for eliminating the tedium that arises from defining things like this over and over again:

  class Order < ActiveRecord::Base
    def self.paid
      find_all_by_paid(true)
    end

    def self.unpaid
      find_all_by_paid(false)
    end

    def mark_as_paid
      update_attribute(:paid, true)
      # related tasks
    end

    def mark_as_unpaid
      update_attribute(:paid, false)
      # related tasks
    end
  end

There’s more information on the Flagger project page. Any feedback – comments, bugs, testing with obscure DBs – is very welcome.

If you’ve enjoyed this article, you might enjoy my recently published book JavaScript Testing Recipes. It’s full of simple techniques for writing modular, maintainable JavaScript apps in the browser and on the server.