class RMonitor::Commands::Invoke

Public Class Methods

new(options = {}) click to toggle source
# File lib/rmonitor/commands/invoke.rb, line 4
def initialize(options = {})
  @profiles = options[:profiles] || Config.new.profiles
  @matcher = options[:matcher] || Matcher.new(options)
  @strategy = options[:strategy] || Strategies::Pessimistic.new(options)
  @factory = options[:factory] || Actions.new(options)
end

Public Instance Methods

execute(name) click to toggle source
# 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