Class: PuppetX::VMware::Mapper::MapComponent

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/vmware/mapper.rb

Direct Known Subclasses

Leaf, Node

Instance Method Summary collapse

Constructor Details

#initialize(input, prop_names) ⇒ MapComponent

Returns a new instance of MapComponent.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/puppet_x/vmware/mapper.rb', line 26

def initialize(input, prop_names)
  # copy input to @props hash
  @props = {}
  input = input.dup
  prop_names.each do |name|
    if input.include? name
      v = input.delete name
      @props[name] =
          if v.respond_to?(:dup)
            begin
              v.dup
            rescue TypeError
              # several classes claim to respond_to?(:dup)
              # but they actually throw a TypeError
              v
            end
          else
            v
          end
    end
  end
  unless input.empty?
    fail "#{self.class} doesn't recognize some input: #{input.inspect}"
  end
end