Module: PuppetX::VMware::Mapper

Defined in:
lib/puppet_x/vmware/mapper.rb

Defined Under Namespace

Classes: ClusterConfigSpecExMap, Leaf, LeafData, Map, MapComponent, Node, NodeData

Class Method Summary collapse

Class Method Details

.munge_to_iObject

This is a set of tiny utilities for defining validation and munging routines in the input tree for Map. Some are simply static blocks wrapped in Proc, while others allow tailoring the block to specific cases.



391
392
393
# File 'lib/puppet_x/vmware/mapper.rb', line 391

def self.munge_to_i
  Proc.new {|v| v.to_i}
end

.munge_to_symObject



405
406
407
408
409
# File 'lib/puppet_x/vmware/mapper.rb', line 405

def self.munge_to_sym
  Proc.new do |v|
    v.to_sym if String === v
  end
end

.munge_to_tfsymsObject



395
396
397
398
399
400
401
402
403
# File 'lib/puppet_x/vmware/mapper.rb', line 395

def self.munge_to_tfsyms
  Proc.new do |v|
    case v
    when FalseClass then :false
    when TrueClass  then :true
    else v
    end
  end
end

.validate_i_ge(low) ⇒ Object



411
412
413
414
415
416
# File 'lib/puppet_x/vmware/mapper.rb', line 411

def self.validate_i_ge(low)
  Proc.new do |v|
    v = Integer v
    fail "value #{v} not greater than nor equal to #{low}" unless low <= v
  end
end

.validate_i_in(range) ⇒ Object



425
426
427
428
429
430
# File 'lib/puppet_x/vmware/mapper.rb', line 425

def self.validate_i_in(range)
  Proc.new do |v|
    v = Integer v
    fail "value #{v} not in '#{range.inspect}'" unless range.include? v
  end
end

.validate_i_le(high) ⇒ Object



418
419
420
421
422
423
# File 'lib/puppet_x/vmware/mapper.rb', line 418

def self.validate_i_le(high)
  Proc.new do |v|
    v = Integer v
    fail "value #{v} not less than nor equal to #{high}" unless v <= high
  end
end