Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/blower/util.rb
Instance Method Summary collapse
-
#let(bindings) ⇒ Object
Yield with temporary instance variable assignments.
Instance Method Details
#let(bindings) ⇒ Object
Yield with temporary instance variable assignments.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/blower/util.rb', line 13 def let (bindings) old_values = bindings.keys.map do |key| instance_variable_get(key) end bindings.each do |key, value| instance_variable_set(key, value) end yield ensure return unless old_values bindings.keys.each.with_index do |key, i| instance_variable_set(key, old_values[i]) end end |