------art_145_31948876.1321288863978
Content-Type: multipart/alternative; 
	boundary---art_146_26743045.1321288863979"

------art_146_26743045.1321288863979
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Well, this seems to work:

  #
  def with(_hash, &_yield)
    _hash  _hash || {}).to_hash
    code  <-END
      define_method(:_with) do |#{_hash.keys.join(',')}|
        binding
      end
    END
    (class << self; self; end).class_eval(code)
    b  with(*_hash.values, &_yield)
    (class << self; self; end).class_eval{ remove_method(:_with) }
    return b
    #eval("Proc.new{ |#{_hash.keys.join(',')}| binding 
}").call(*_hash.values)
  end

But alas, now I am loosing the context of original binding. Why is that? I 
thought define_method kept closure.


------art_146_26743045.1321288863979
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<div>Well, this seems to work:</div><div><br></div><div>&nbsp; #</div><div>&nbsp; def with(_hash, &amp;_yield)</div><div>&nbsp; &nbsp; _hash  _hash || {}).to_hash</div><div>&nbsp; &nbsp; code  lt;&lt;-END</div><div>&nbsp; &nbsp; &nbsp; define_method(:_with) do |#{_hash.keys.join(',')}|</div><div>&nbsp; &nbsp; &nbsp; &nbsp; binding</div><div>&nbsp; &nbsp; &nbsp; end</div><div>&nbsp; &nbsp; END</div><div>&nbsp; &nbsp; (class &lt;&lt; self; self; end).class_eval(code)</div><div>&nbsp; &nbsp; b  with(*_hash.values, &amp;_yield)</div><div>&nbsp; &nbsp; (class &lt;&lt; self; self; end).class_eval{ remove_method(:_with) }</div><div>&nbsp; &nbsp; return b</div><div>&nbsp; &nbsp; #eval("Proc.new{ |#{_hash.keys.join(',')}| binding }").call(*_hash.values)</div><div>&nbsp; end</div><div><br></div><div>But alas, now I am loosing the context of original binding. Why is that? I thought define_method kept closure.<br></div><div><br></div>
------art_146_26743045.1321288863979--

------art_145_31948876.1321288863978--