Advanced rails reading notes

Written by Keith McDonnell. Last updated on Thursday, February 02, 2012.

== Questions
How useful is the Ruby C level class model intro? => Not obvious
What is the output – blog material ?

Diamond problem → last included modules methods are called

class Foo
include Bar
include Baz
end { return :foo } # returns from calling function

Closure: each gets a separate instance of the variable

def make_counter(i=0)

x = make_counter # => 1 # => 2

y = make_counter # => 1 # => 2

Check out generate_read_method

A binding is the set of variables and methods that are available at a
particular (lexical) point in the code.


Method chaining

If you want to over-ride an existing method using an included module, you must
use class_eval and alias_method_chain:

C.class_eval { alias_method_chain :test_method, :module }

Higher-order functions are functions that operate on
other functions. Higher-order functions usually either take one or more functions as
an argument or return a function.

If you'd like to discuss this article, you can send me an email and/or publish an article online and link back to this page.