Skip to content

Commit

Permalink
Added new sections: Interesting Articles and Small Snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbb committed Jun 3, 2009
1 parent 3ac93f4 commit c4cbf57
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
@@ -1,7 +1,7 @@
Ruby Metaprogramming Study Note
===============================
I'm now taking a sniff of Ruby Metaprogramming. This is my tiny Study Note. :)
May 23th, 2009 by ashbb (Satoshi Asakawa)
Jun 3rd, 2009 by ashbb (Satoshi Asakawa)


Videos
Expand Down Expand Up @@ -42,6 +42,19 @@ Sample Apps
Very simple Ruby DSL on Shoes.


Interesting Articles
--------------------
- [Seeing Metaclasses Clearly](http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html)
- [Extending your include knowledge of Ruby](http://macournoyer.wordpress.com/2007/07/06/extending-your-include-knowledge-of-ruby/)
- [Using methodmissing and respondto? to create dynamic methods](http://technicalpickles.com/posts/using-method_missing-and-respond_to-to-create-dynamic-methods)
- [Ola Bini's blogs on Meta programming](http://ola-bini.blogspot.com/search/label/metaprogramming)


Small Snippets
--------------
- [ss001](http://github.com/ashbb/ruby_metaprogramming_study_note/tree/master/snippets/ss001.md): nested def keyword


To do list
----------
- create more sample codes
Expand Down
27 changes: 27 additions & 0 deletions snippets/ss001.md
@@ -0,0 +1,27 @@
ss001: nested def keyword
-------------------------

# small snippet 001
class Dog
def say
def cry
def bark
puts 'Wooo!'
end
end
end
end

d = Dog.new
p Dog.instance_methods(false) #=> ["say"]
d.say
p Dog.instance_methods(false) #=> ["say", "cry"]
d.cry
p Dog.instance_methods(false) #=> ["say", "bark", "cry"]
d.bark #=> Wooo!


The method is actually created dinamically.
The method `cry` is not created until the method `say` is executed.

For more information: [Dynamically created methods in Ruby](http://ola-bini.blogspot.com/2008/05/dynamically-created-methods-in-ruby.html)

0 comments on commit c4cbf57

Please sign in to comment.