def inside def: "It's undocumented and should not be used nor touched."
http://redmine.ruby-lang.org/issues/show/797

Also, there is nothing gained with def inside def.  It is equivalent to 
adding a method to the singleton class, but without the ability to 
reference variables from the enclosing binding.

class A
  def f
    x = 3
    # note: Object#singleton_class makes this cleaner
    (class << self ; self ; end).instance_eval {
      define_method(:g) {
        puts x
      }
    }
  end
end

a = A.new
a.f
a.g  #=> 3

class B
  def f
    x = 9
    def g
      puts x
    end
  end
end

b = B.new
b.f
b.g  #=> undefined local variable or method `x'
-- 
Posted via http://www.ruby-forum.com/.