Class: Dslh::ScopeBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/dslh.rb

Overview

of Scope

Class Method Summary collapse

Class Method Details

.nest(bind, block_var) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/dslh.rb', line 199

def self.nest(bind, block_var)
  eval(<<-EOS, bind)
    if #{block_var}
      __hash_orig = @__hash__
      @__hash__ = {}
      self.instance_eval(&#{block_var})
      __nested_hash = @__hash__
      @__hash__ = __hash_orig
      __nested_hash
    else
      nil
    end
  EOS
end