Module: Caco::Facter::ClassMethods

Included in:
Caco::Facter
Defined in:
lib/caco/facter.rb

Constant Summary collapse

@@fake_data =
nil

Instance Method Summary collapse

Instance Method Details

#call(*items) ⇒ Object

Raises:



20
21
22
23
24
# File 'lib/caco/facter.rb', line 20

def call(*items)
  value = json_data(*items).dig(*items)
  raise KeyNotFoundError.new("#{items.join(":")} not found") unless value
  value
end

#set_fake_data=(data) ⇒ Object



7
8
9
# File 'lib/caco/facter.rb', line 7

def set_fake_data=(data)
  @@fake_data = data
end

#use_fake(data, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/caco/facter.rb', line 11

def use_fake(data, &block)
  old_fake_data = @@fake_data
  @@fake_data = data

  yield

  @@fake_data = old_fake_data
end