Skip to content

Instantly share code, notes, and snippets.

@danreedy
Created May 23, 2011 19:05
Show Gist options
  • Save danreedy/987305 to your computer and use it in GitHub Desktop.
Save danreedy/987305 to your computer and use it in GitHub Desktop.
Example Method_Missing code for an approval model
class Approval
attr_accessor :status
def method_missing(meth, *args, &blk)
method_name = meth.to_s
if method_name =~ /\?$/
self.status.downcase.eql? method_name.gsub(/\?$/,'')
else
super
end
end
end
a = Approval.new
a.status = "Pending"
puts a.pending?
puts a.approved?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment