Forum: Ruby on Rails editing method_missing

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.
D038c5d90a88bf31c73b300f73860126?d=identicon&s=25 Fernando Poblete (fipa)
on 2007-01-25 15:25
Hello
I need to load external data from files coming from different sources so
I need to standardize a lot. What I want to do (after a proper file
processing) would be something like:

person.name = format_name(array[0])
person.last_name = format_last_name(array[1])
person.country = format_country(array[2])
person.email = format_email(array[3])
person.website = format_website(array[4])

The thing is what most of those format_xxx methods
(name,last_name,country,...) do is just capitalize the input so I would
like to have a default method that catches all the format_xxx calls,
except those that need some special formatting -like email or website-
and that will have an ad-hoc -application level- format method.

I'm thinking in adding some code to method_missing in base.rb. Is this a
good idea? If so, how could it be? Or is there a better way to do it?

thanks

PD. IT's my first post here... great community.
This topic is locked and can not be replied to.