Class: Specinfra::HostInventory

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/specinfra/host_inventory.rb,
lib/specinfra/host_inventory/ec2.rb,
lib/specinfra/host_inventory/fqdn.rb,
lib/specinfra/host_inventory/domain.rb,
lib/specinfra/host_inventory/memory.rb,
lib/specinfra/host_inventory/hostname.rb

Defined Under Namespace

Classes: Domain, Ec2, Fqdn, Hostname, Memory

Instance Method Summary collapse

Constructor Details

#initializeHostInventory

Returns a new instance of HostInventory.



11
12
13
14
# File 'lib/specinfra/host_inventory.rb', line 11

def initialize
  property[:host_inventory] ||= {}
  @inventory = property[:host_inventory]
end

Instance Method Details

#[](key) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/specinfra/host_inventory.rb', line 16

def [](key)
  @inventory[key.to_sym] ||= {}
  if @inventory[key.to_sym].empty?
    inventory_class = Specinfra::HostInventory.const_get(key.to_s.to_camel_case)
    @inventory[key.to_sym] = inventory_class.get
  end
  @inventory[key.to_sym]
end