Module.new with class_eval

Posted by dorelal on Stack Overflow See other posts from Stack Overflow or by dorelal
Published on 2010-05-11T21:51:50Z Indexed on 2010/05/11 21:54 UTC
Read the original article Hit count: 82

Filed under:

This is a large commit. But I want you to concentrate on this change block. http://github.com/rails/rails/commit/d916c62cfc7c59ab6411407a05b946d3dd7535e9#L2L1304

Even without understanding the full context of the code I am not able to think of a scenario where I would use

include Modue.new { class_eval <<-RUBY def foo puts 'foo' end RUBY }

Then end result is that in the root context (self just before include Moduel.new) a method call foo has been added.

If I take out the Module.new code and if I only leave class_eval in that case also I will have a method called foo in self.

What am I missing.

© Stack Overflow or respective owner

Related posts about ruby-on-rails