Class: Puppet::Property::F5truthy

Inherits:
Puppet::Property
  • Object
show all
Defined in:
lib/puppet/property/f5_truthy.rb

Class Method Summary collapse

Class Method Details

.truthy_property(desc = nil, trueval = :enabled, falseval = :disabled) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet/property/f5_truthy.rb', line 4

def self.truthy_property(desc=nil, trueval=:enabled, falseval=:disabled)
  options = [:yes, :no, :true, :false, :enabled, :disabled]
  desc "#{desc or "Undocumented attribute."}
  Valid options: <#{options.join("|")}>"

  validate do |value|
    unless options.include?(value.to_s.to_sym)
      raise ArgumentError, "#{name} must be one of: #{options.join(", ")}."
    end
  end
  munge do |value|
    case value.to_s.to_sym
    when :true, :enabled, :yes
      trueval
    when :false, :disabled, :no
      falseval
    end
  end
end