method_missing , Ah Ruby-Wah Ruby
August 30th, 2006
This is about method_missing featured of ruby, which I had used recently in SimpleTicket well, its Ver2.0 of SimpleTicket, at Architel soon to be used in-house first.afterwards will be released as open-source project.
it creates methods like,
- `status_to_open`
- `status_to_contacted`
- `status_to_pending`
- `status_to_closed`
changes status of ticket as their name suggests
def method_missing(method_id, *arguments)
if mdata = /status_to_(open|closed|contacted|pending)/.match(method_id.to_s)
status = mdata.captures.first
change_status(Status.find_by_name(status.capitalize).id)
else
super
end
end
I’m loving Ruby
Sorry, comments are closed for this article.