CSC/ECE 517 Fall 2007/wiki1b 2 Method Missing: Difference between revisions
No edit summary |
|||
Line 17: | Line 17: | ||
This section covers how we can use Method Missing to provide a very comprehensive list of API methods in a class, with a little amount of code. Lets assume that we are creating a flickr(www.flickr.com) search API class. What could be the interface of this class? Well basically, the purpose of this class would be to provide a variety of methods using which developers can search photos in flickr database. For example, the following methods could be provided in the Flickr Search API: | This section covers how we can use Method Missing to provide a very comprehensive list of API methods in a class, with a little amount of code. Lets assume that we are creating a flickr(www.flickr.com) search API class. What could be the interface of this class? Well basically, the purpose of this class would be to provide a variety of methods using which developers can search photos in flickr database. For example, the following methods could be provided in the Flickr Search API: | ||
flickr.search("Wolfpack") | |||
flickr.search_by_tag("Sports") | |||
flickr.search_by_user("Vinay") | |||
flickr.search_by_content_type("paintings","Monalisa") | |||
flickr.search_free_photos("Million dollar Art") | |||
flickr.search_within_date("10/1/2007","11/1/2007") | |||
== Creating Dynamic Methods on the Fly! == | == Creating Dynamic Methods on the Fly! == |
Revision as of 17:34, 1 October 2007
"There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them."
A world without "Method Missing"
What is "Method Missing" and what the fuss is all about ???
"Method Missing for Dummies" Example!
-> http://rubylearning.com/satishtalim/ruby_method_missing.html
Provide Cool APIs with Method Missing!
@ http://ajax.stealthsettings.com/rubyisms-in-rails/metaprogramming/
This section covers how we can use Method Missing to provide a very comprehensive list of API methods in a class, with a little amount of code. Lets assume that we are creating a flickr(www.flickr.com) search API class. What could be the interface of this class? Well basically, the purpose of this class would be to provide a variety of methods using which developers can search photos in flickr database. For example, the following methods could be provided in the Flickr Search API:
flickr.search("Wolfpack") flickr.search_by_tag("Sports") flickr.search_by_user("Vinay") flickr.search_by_content_type("paintings","Monalisa") flickr.search_free_photos("Million dollar Art") flickr.search_within_date("10/1/2007","11/1/2007")
Creating Dynamic Methods on the Fly!
-> http://redhanded.hobix.com/inspect/hatchingNewMethodsInMidAir.html
Build your own DSL with Ruby!
-> http://liquiddevelopment.blogspot.com/2006/04/twisting-and-shaping-dsls-using-ruby.html , http://riffraff.blogsome.com/2006/05/02/metaprogramming-breakfast/