Class: RMonitor::Commands::Invoke
- Inherits:
-
Object
- Object
- RMonitor::Commands::Invoke
- Defined in:
- lib/rmonitor/commands/invoke.rb
Instance Method Summary collapse
- #execute(name) ⇒ Object
-
#initialize(options = {}) ⇒ Invoke
constructor
A new instance of Invoke.
Constructor Details
#initialize(options = {}) ⇒ Invoke
Returns a new instance of Invoke.
4 5 6 7 8 9 |
# File 'lib/rmonitor/commands/invoke.rb', line 4 def initialize( = {}) @profiles = [:profiles] || Config.new.profiles @matcher = [:matcher] || Matcher.new() @strategy = [:strategy] || Strategies::Pessimistic.new() @factory = [:factory] || Actions.new() end |
Instance Method Details
#execute(name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rmonitor/commands/invoke.rb', line 11 def execute(name) profile = @profiles.find { |p| p[:name] == name } raise UnknownProfileError unless profile raise UninvokableProfileError unless @matcher.invokable?(profile) actions = @factory.create(profile) @strategy.execute(actions) end |