Thom Lawrence

Can haz pluginz?

July 11, 2008 · Leave a Comment

require 'rubygems'
require 'active_record'

class ActiveRecord::Base
  class << self
   def method_missing_with_lol(sym)
     if sym.to_s =~ /^can_haz_(\w+)?/
       send "acts_as_#{$1}"
     else
       method_missing_without_lol sym
     end
   end
   alias_method_chain :method_missing, :lol
 end
end

class Lulz < ActiveRecord::Base
  can_haz_state_machine?
end

Temporary solution for Aaron’s problem, anyway. ;)

Categories: Code · Ruby
Tagged: , , ,