Class: VagrantPlugins::PuppetFactGenerator::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-puppet-fact-generator/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
# File 'lib/vagrant-puppet-fact-generator/config.rb', line 6

def initialize
  @facts = UNSET_VALUE
end

Instance Attribute Details

#factsObject

Returns the value of attribute facts.



4
5
6
# File 'lib/vagrant-puppet-fact-generator/config.rb', line 4

def facts
  @facts
end

Instance Method Details

#add_fact(fact_name, value) ⇒ Object



17
18
19
20
# File 'lib/vagrant-puppet-fact-generator/config.rb', line 17

def add_fact(fact_name, value)
  facts = get_facts()
  facts[fact_name] = value
end

#finalize!Object



22
23
24
# File 'lib/vagrant-puppet-fact-generator/config.rb', line 22

def finalize!
  @facts = {} if @facts == UNSET_VALUE
end

#get_factsObject



10
11
12
13
14
15
# File 'lib/vagrant-puppet-fact-generator/config.rb', line 10

def get_facts
  if @facts == UNSET_VALUE
    @facts = {}
  end
  return @facts
end

#validate(machine) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/vagrant-puppet-fact-generator/config.rb', line 26

def validate(machine)
  errors = []
  if @facts and not @facts.kind_of?(Hash)
    errors << '`facts` must be a hash of form fact_name => fact_value'
  end

  return {'puppet_fact_generator' => errors}
end