Class: PuppetX::VMware::Mapper::Leaf
- Inherits:
-
MapComponent
- Object
- MapComponent
- PuppetX::VMware::Mapper::Leaf
- Defined in:
- lib/puppet_x/vmware/mapper.rb
Constant Summary collapse
- Prop_names =
[ :desc, :misc, :munge, :olio, :path_is_now, :path_should, :prop_name, :requires, :requires_siblings, :validate, :valid_enum, ]
Instance Method Summary collapse
-
#initialize(input) ⇒ Leaf
constructor
A new instance of Leaf.
Constructor Details
#initialize(input) ⇒ Leaf
Returns a new instance of Leaf.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/puppet_x/vmware/mapper.rb', line 91 def initialize input # copy input to @props hash super input, Prop_names # check for required values fail "#{self.class} doesn't include 'path_should'" unless @props[:path_should] @props[:misc] ||= [] @props[:olio] ||= {} @props[:requires] ||= [] @props[:requires_siblings] ||= [] # set defaults and munge @props[:path_is_now] ||= @props[:path_should] # .dup not necessary because of following map to_sym @props[:path_is_now] = @props[:path_is_now].map{|v| v.to_sym} @props[:path_should] = @props[:path_should].map{|v| v.to_sym} @props[:prop_name] = case @props[:prop_name] when nil # autogenerate using last element in path PuppetX::VMware::Util.snakeize(@props[:path_should][-1]).to_sym when PROP_NAME_IS_FULL_PATH # autogenerate using full path x = @props[:path_should]. map{|name| PuppetX::VMware::Util.snakeize name}. join "_" x = x.to_sym else # specified explicitly in map @props[:prop_name] end end |