Module: Assert::Context::LetDSL

Included in:
Assert::Context
Defined in:
lib/assert/context/let_dsl.rb

Instance Method Summary collapse

Instance Method Details

#let(name, &block) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/assert/context/let_dsl.rb', line 7

def let(name, &block)
  send(:define_method, name, &->{
    unless instance_variable_defined?("@__assert_let_#{name}__")
      instance_variable_set(
        "@__assert_let_#{name}__",
        instance_eval(&block),
      )
    end

    instance_variable_get("@__assert_let_#{name}__")
  })
end