The If Works This dirt was a building before

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.


1 Comment

A sure cure for seasickness is to sit under a tree — Spike Milligan

Posted by Bitter jurisdiction on 22 October 2007 @ 6am

Leave a Comment