Class: Onuro::Event

Inherits:
Object
  • Object
show all
Includes:
ExecutionResult, Loggable
Defined in:
lib/onuro/event.rb

Constant Summary

Constants included from ExecutionResult

Onuro::ExecutionResult::FAILURE, Onuro::ExecutionResult::NO_PROCESSABLE, Onuro::ExecutionResult::SUCCESSFUL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#logger, logger, logger_file

Constructor Details

#initialize(name, ruleset_stage: [], event_strategy: DefaultEventStrategy.new) ⇒ Event

Returns a new instance of Event.



17
18
19
20
21
# File 'lib/onuro/event.rb', line 17

def initialize(name, ruleset_stage: [], event_strategy: DefaultEventStrategy.new)
  self.name = name
  self.event_strategy = event_strategy
  @ruleset_stage = ruleset_stage
end

Instance Attribute Details

#event_strategyObject

Returns the value of attribute event_strategy.



9
10
11
# File 'lib/onuro/event.rb', line 9

def event_strategy
  @event_strategy
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/onuro/event.rb', line 8

def name
  @name
end

#ruleset_stageObject (readonly)

Returns the value of attribute ruleset_stage.



8
9
10
# File 'lib/onuro/event.rb', line 8

def ruleset_stage
  @ruleset_stage
end

Instance Method Details

#add_rule_stage(rule_stage) ⇒ Object



27
28
29
# File 'lib/onuro/event.rb', line 27

def add_rule_stage(rule_stage)
  ruleset_stage << rule_stage
end

#add_ruleset_stage(ruleset_stage) ⇒ Object



23
24
25
# File 'lib/onuro/event.rb', line 23

def add_ruleset_stage(ruleset_stage)
  @ruleset_stage += ruleset_stage
end

#execute(context = {}) ⇒ Object



31
32
33
34
# File 'lib/onuro/event.rb', line 31

def execute(context = {})
  result = execution_flow(context)
  execution_result(SUCCESSFUL, result[:processed], result[:failed])
end