Method: DynamicVariable#with

Defined in:
lib/dynamic_variable.rb

#with(*pairs) ⇒ Object

with {}

varible defaults to default_variable
value defaults to nil

with(value) { block }

variable defaults to default_variable

with(variable, value) { block }

with(variable_1, value_1, …, variable_n_1, value_n_1, value_n) { block }

variable_n defaults to default_variable

with(variable_1, value_1, …, variable_n, value_n) { block }



40
41
42
43
44
45
46
47
48
# File 'lib/dynamic_variable.rb', line 40

def with(*pairs)
  pairs = [nil] if pairs.empty?
  begin
    push_pairs(pairs)
    yield(self)
  ensure
    pop_pairs(pairs)
  end
end