Class: PuppetDB::Model::Fact

Inherits:
Base
  • Object
show all
Defined in:
lib/puppetdb/model/fact.rb

Overview

Parses fact_contents from PuppetDB

All attributes retreived from the puppetdb be added as getter to the object

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, client=, get, query, request

Constructor Details

#initialize(attributes) ⇒ Fact

Returns a new instance of Fact.



9
10
11
12
# File 'lib/puppetdb/model/fact.rb', line 9

def initialize(attributes)
  super(**attributes)
  self.name = attributes[:name]
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/puppetdb/model/fact.rb', line 7

def name
  @name
end

Instance Method Details

#to_sObject



30
31
32
# File 'lib/puppetdb/model/fact.rb', line 30

def to_s
  value
end

#valueObject

gets the value for the fact and certname combination

The value of value is lazy loaded on call and saved in the object



25
26
27
28
# File 'lib/puppetdb/model/fact.rb', line 25

def value
  pql = "fact_contents[value] { certname = '#{certname}' and path = #{@path}}"
  @value ||= self.class.request(pql).first.values
end