Class: RubyReactor::Template::Result

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_reactor/template/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_name, path = nil) ⇒ Result

Returns a new instance of Result.



8
9
10
11
12
# File 'lib/ruby_reactor/template/result.rb', line 8

def initialize(step_name, path = nil)
  super()
  @step_name = step_name
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/ruby_reactor/template/result.rb', line 6

def path
  @path
end

#step_nameObject (readonly)

Returns the value of attribute step_name.



6
7
8
# File 'lib/ruby_reactor/template/result.rb', line 6

def step_name
  @step_name
end

Instance Method Details

#inspectObject



25
26
27
28
29
30
31
# File 'lib/ruby_reactor/template/result.rb', line 25

def inspect
  if @path
    "result(:#{@step_name}, #{@path.inspect})"
  else
    "result(:#{@step_name})"
  end
end

#resolve(context) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_reactor/template/result.rb', line 14

def resolve(context)
  value = context.get_result(@step_name)
  return nil if value.nil?

  if @path
    extract_path(value, @path)
  else
    value
  end
end