Class: ConfigurationGroup

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/models/configuration_group.rb

Overview

Hold a collection of app configuration items as a group.

Contains the actual key value pairs as well as the rules that apply to this configuration group.

Instance Method Summary collapse

Instance Method Details

#agent_payloadObject

Return the configuration doc for the agent



47
48
49
# File 'lib/models/configuration_group.rb', line 47

def agent_payload
  { name: name, version: version, items: options.collect(&:agent_payload) }
end

#match_agent?(agent) ⇒ Boolean

Return true if the configuration rules match this agent

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
42
# File 'lib/models/configuration_group.rb', line 34

def match_agent?(agent)
  return false unless active?

  match = true
  configuration_rules.where(active: true).each { |rule| match &&= rule.match_agent?(agent) }
  match
rescue StandardError
  false
end