Class: Thoreau::Model::Outcome

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/thoreau/model/outcome.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, logger, #logger

Constructor Details

#initialize(output: nil, exception: nil) ⇒ Outcome

Returns a new instance of Outcome.



17
18
19
20
21
22
23
24
25
26
# File 'lib/thoreau/model/outcome.rb', line 17

def initialize output: nil,
               exception: nil

  if output.is_a?(Proc)
    @output_proc = output
  else
    @output = output
  end
  @exception = exception
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



15
16
17
# File 'lib/thoreau/model/outcome.rb', line 15

def exception
  @exception
end

#outputObject (readonly)

Returns the value of attribute output.



14
15
16
# File 'lib/thoreau/model/outcome.rb', line 14

def output
  @output
end

Instance Method Details

#evaluate(result, context) ⇒ Object



28
29
30
# File 'lib/thoreau/model/outcome.rb', line 28

def evaluate(result, context)
  @output = context.instance_exec(result, &(@output_proc)) if @output_proc
end