Class: Onuro::Engine
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Loggable
#logger, logger, logger_file
Constructor Details
#initialize ⇒ Engine
Returns a new instance of Engine.
45
46
47
48
49
|
# File 'lib/onuro/engine.rb', line 45
def initialize
self.events = Engine.configuration.events.clone
end
|
Class Attribute Details
.configuration ⇒ Object
Returns the global [EngineConfiguration](Onuro/EngineConfiguration) object. While you can use this method to access the configuration, the more common convention is to use [Onuro::Engine.configure](Onuro::Engine#configure-class_method).
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
7
8
9
|
# File 'lib/onuro/engine.rb', line 7
def events
@events
end
|
Class Method Details
Yields the global configuration to a block.
41
42
43
|
# File 'lib/onuro/engine.rb', line 41
def self.configure
yield configuration if block_given?
end
|
.instance ⇒ Object
51
52
53
|
# File 'lib/onuro/engine.rb', line 51
def self.instance
new
end
|
.reset ⇒ Object
Users must invoke this if they want to have the configuration reset when they use the runner multiple times within the same process. Users must deal themselves with re-configuration of Onuro::Engine before run.
29
30
31
|
# File 'lib/onuro/engine.rb', line 29
def self.reset
@configuration = nil
end
|
Instance Method Details
#add_event(event) ⇒ Object
55
56
57
58
|
# File 'lib/onuro/engine.rb', line 55
def add_event(event)
events[event.name] = event
self
end
|
#add_events(new_events) ⇒ Object
60
61
62
63
|
# File 'lib/onuro/engine.rb', line 60
def add_events(new_events)
new_events.each { |event| add_event(event) }
self
end
|
#delete_event!(event_name) ⇒ Object
69
70
71
72
|
# File 'lib/onuro/engine.rb', line 69
def delete_event!(event_name)
result = events.delete(event_name)
raise InvalidEventNameException unless result
end
|
#event?(event_name) ⇒ Boolean
65
66
67
|
# File 'lib/onuro/engine.rb', line 65
def event?(event_name)
events.key?(event_name)
end
|
#execute(event_name, context = Context.new) ⇒ Object