This is a very simple file to show how to add 'act_as_whatever' to ActiveRecord.
To use it, put the code into a file like lib/your_super_name/acts/idiot.rb and voilà.
Thanks to technoweenie for "acts_as_paranoid" which I used with "acts_as_tree" to build this template.
module YourSuperName
module Acts
module Idiot
def self.included(base)
base.extend AddActsAsMethod
end
module AddActsAsMethod
def acts_as_idiot
class_eval <<-END
include YourSuperName::Acts::Idiot::InstanceMethods
END
end
end
module InstanceMethods
def self.included(aClass)
aClass.extend ClassMethods
end
def idiot(msg)
"#{self}: I am an idiotic object. And I say '#{msg}'."
end
module ClassMethods
def idiot(msg)
"#{self}: I am an idiotic class. And I say '#{msg}'."
end
end
end
end
end
end
ActiveRecord::Base.send :include, YourSuperName::Acts::Idiot