Class: RecursiveOpenStruct

Inherits:
Object show all
Defined in:
lib/puppet_x/puppetlabs/kubernetes/provider.rb

Instance Method Summary (collapse)

Instance Method Details

Method: RecursiveOpenStruct#ensure_value_at_path

Defined in:
lib/puppet_x/puppetlabs/kubernetes/provider.rb

- (Object) ensure_value_at_path(klass, path, value)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/puppet_x/puppetlabs/kubernetes/provider.rb', line 10

def ensure_value_at_path(klass, path, value)
  path.each_with_index.inject(self) { |obj, (attr, index)|
    if index == (path.size - 1)
      obj.send("#{attr}=", value)
    else
      if attr.class == Fixnum
        if obj.send(:at, attr).nil?
          obj.append(Object::const_get("Kubeclient::#{klass}").new)
        end
        obj.send(:at, attr)
      else
        obj.send(attr)
      end
    end
  }
end