Issue #7872 has been reported by alexeymuranov (Alexey Muranov).

----------------------------------------
Bug #7872: `block_given?` does not work inside `define_method`
https://bugs.ruby-lang.org/issues/7872

Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 
ruby -v: 2.0.0-rc2


=begin
Is this the expected behavior?

 define_method :try do
   block_given? ? yield : 'no block'
 end

 try { 'block' } # => "no block"

However:

 def try_again
   block_given? ? yield : 'no block'
 end

 try_again { 'block' } # => "block"

=end



-- 
http://bugs.ruby-lang.org/