Forum: Ruby on Rails New plugin: Flagger

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
jcoglan@googlemail.com (Guest)
on 2007-03-09 18:06
(Received via mailing list)
Hi all,

I've just put out a plugin for ActiveRecord that stops you having to
write repetitive bundles of methods such as

  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

It gives you dynamic attribute-based methods similar to these. You can
use certain negative prefixes to look for false values - Order.unpaid
returns orders where paid is false - and chain attributes together, as
in Order.paid_and_delivered, Cocktail.shaken_but_not_stirred, etc.
More info here:

http://blog.jcoglan.com/flagger/

I'd really appreciate a few people kicking its tyres in anything other
than MySQL, or in Rails versions 1.0.x (is anyone still using those).
Comments/bugs/test reports are always welcome.
This topic is locked and can not be replied to.