Class: RMonitor::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rmonitor/matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Matcher

Returns a new instance of Matcher.



3
4
5
# File 'lib/rmonitor/matcher.rb', line 3

def initialize(options = {})
  @capabilities = options[:capabilities] || Capabilities.new(options).parse
end

Instance Method Details

#invokable?(profile) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
# File 'lib/rmonitor/matcher.rb', line 7

def invokable?(profile)
  return false if profile.has_key?(:only_if) && !profile[:only_if].call
  return false if profile.has_key?(:not_if) && profile[:not_if].call

  profile[:devices].all? do |device|
    has_desired_capability? device
  end
end