Class: PuppetX::VMware::Mapper::MapComponent
- Inherits:
-
Object
- Object
- PuppetX::VMware::Mapper::MapComponent
- Defined in:
- lib/puppet_x/vmware/mapper.rb
Instance Method Summary collapse
-
#initialize(input, prop_names) ⇒ MapComponent
constructor
A new instance of MapComponent.
Constructor Details
#initialize(input, prop_names) ⇒ MapComponent
Returns a new instance of MapComponent.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet_x/vmware/mapper.rb', line 8 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 |