Thursday, May 12, 2011

[Rails] Ruby Metaprogramming

Hi,
I am working with a project where I am writing the following code:-

store_fb_other_information(profile_obj, "activity", fb_activities,
provider, :activity, profile_obj.activity_information,
ActivityInformation)
#Book Information
store_fb_other_information(profile_obj, "book", fb_books, provider,
:book, profile_obj.book_information, BookInformation)
#Interest Information
store_fb_other_information(profile_obj, "interest", fb_interests,
provider, :interest, profile_obj.interest_information,
InterestInformation)
#Movie Information
store_fb_other_information(profile_obj, "movie", fb_movies, provider,
:movie, profile_obj.movie_information, MovieInformation)

If you look at the code I am calling the same function multiple times
only parameters are different.

Can I refactor the above code using metaprogramming If yes how?

Thanks,
Mike

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate