Class: Snmp2mkr::ConfigTypes::Template

Inherits:
Base
  • Object
show all
Defined in:
lib/snmp2mkr/config_types/template.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#binded_context

Instance Method Summary collapse

Methods inherited from Base

#bind_context, #children, #evaluate, #initialize, #inspect

Constructor Details

This class inherits a constructor from Snmp2mkr::ConfigTypes::Base

Instance Attribute Details

#interfacesObject (readonly)

Returns the value of attribute interfaces.



38
39
40
# File 'lib/snmp2mkr/config_types/template.rb', line 38

def interfaces
  @interfaces
end

#metaObject (readonly)

Returns the value of attribute meta.



38
39
40
# File 'lib/snmp2mkr/config_types/template.rb', line 38

def meta
  @meta
end

#metric_discoveriesObject (readonly)

Returns the value of attribute metric_discoveries.



38
39
40
# File 'lib/snmp2mkr/config_types/template.rb', line 38

def metric_discoveries
  @metric_discoveries
end

#metricsObject (readonly)

Returns the value of attribute metrics.



38
39
40
# File 'lib/snmp2mkr/config_types/template.rb', line 38

def metrics
  @metrics
end

#nameObject (readonly)

Returns the value of attribute name.



38
39
40
# File 'lib/snmp2mkr/config_types/template.rb', line 38

def name
  @name
end

#templatesObject (readonly)

Returns the value of attribute templates.



38
39
40
# File 'lib/snmp2mkr/config_types/template.rb', line 38

def templates
  @templates
end

#vhost_discoveriesObject (readonly)

Returns the value of attribute vhost_discoveries.



38
39
40
# File 'lib/snmp2mkr/config_types/template.rb', line 38

def vhost_discoveries
  @vhost_discoveries
end

Instance Method Details

#collect_childrenObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/snmp2mkr/config_types/template.rb', line 27

def collect_children
  [
    @templates,
    @metrics,
    @meta,
    @interfaces,
    @metric_discoveries,
    @vhost_discoveries,
  ].compact
end

#setup(kv) ⇒ Object

Raises:

  • (TypeError)


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/snmp2mkr/config_types/template.rb', line 13

def setup(kv)
  raise TypeError, "#{self.class} must be given an Array (BUG?)" unless kv.kind_of?(Array) && kv.size == 2
  k, hash = kv
  @name = k
  raise TypeError, "#{self.class} must be given a Hash" unless hash.kind_of?(Hash)

  @templates = hash.key?('templates') ? TemplatesList.new(hash['templates']) : nil
  @metrics = hash.key?('metrics') ? MetricDefinitionCollection.new(hash['metrics']) : nil
  @meta = hash.key?('meta') ? MetaDefinition.new(hash['meta']) : nil
  @interfaces = hash.key?('interfaces') ? InterfacesDefinition.new(hash['interfaces']) : nil
  @metric_discoveries = hash.key?('metric_discoveries') ? MetricDiscoveryRuleCollection.new(hash['metric_discoveries']) : nil
  @vhost_discoveries = hash.key?('vhost_discoveries') ? VhostDiscoveryRuleCollection.new(hash['vhost_discoveries']) : nil
end