Class: LogStash::ConvergeResult::ActionResult

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/converge_result.rb

Direct Known Subclasses

FailedAction, SuccessfulAction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActionResult

Returns a new instance of ActionResult.



11
12
13
# File 'lib/logstash/converge_result.rb', line 11

def initialize
  @executed_at = LogStash::Timestamp.now
end

Instance Attribute Details

#executed_atObject (readonly)

Returns the value of attribute executed_at.



9
10
11
# File 'lib/logstash/converge_result.rb', line 9

def executed_at
  @executed_at
end

Class Method Details

.create(action, action_result) ⇒ Object

Until all the action have more granularity in the validation or execution we make the ConvergeResult works with primitives and exceptions



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/logstash/converge_result.rb', line 17

def self.create(action, action_result)
  if action_result.is_a?(ActionResult)
    action_result
  elsif action_result.is_a?(Exception)
    FailedAction.from_exception(action_result)
  elsif action_result == true
    SuccessfulAction.new
  elsif action_result == false
    FailedAction.from_action(action, action_result)
  else
    raise LogStash::Error, "Don't know how to handle `#{action_result.class}` for `#{action}`"
  end
end