Class: WatcherAction::MetaAction
- Defined in:
- lib/watcher_action/meta_action.rb
Overview
An action to call other actions. This can be used to “aggregate” combinations of actions that should always go together, so that the same combinations do not have to repeated multiple times
Options
- actions
-
A list of the actions that should be executed. (required)
Instance Method Summary collapse
- #add_action(action) ⇒ Object
- #execute(event) ⇒ Object
-
#initialize(config) ⇒ MetaAction
constructor
A new instance of MetaAction.
Constructor Details
#initialize(config) ⇒ MetaAction
Returns a new instance of MetaAction.
12 13 14 15 |
# File 'lib/watcher_action/meta_action.rb', line 12 def initialize(config) actions = config.get_list(:actions, false) actions.each { |ac| add_action(ac) } end |
Instance Method Details
#add_action(action) ⇒ Object
21 22 23 24 25 |
# File 'lib/watcher_action/meta_action.rb', line 21 def add_action(action) @actions ||= [] raise(ArgumentError, "Trying to add myself, creating a loop.") if(WatcherAction.is_action?(action, self)) @actions << action end |
#execute(event) ⇒ Object
17 18 19 |
# File 'lib/watcher_action/meta_action.rb', line 17 def execute(event) @actions.each { |ac| WatcherAction.run_action(ac, event) } end |