Sha256: 50cbc39694cd82c8e621b87bda415a96cc9ba08e31ebc69d55ac1fbf05692ca6

Contents?: true

Size: 704 Bytes

Versions: 7

Compression:

Stored size: 704 Bytes

Contents

# Various methods used to coerce values into a canonical form.
#
# @api private
module Puppet::Coercion
  # Try to coerce various input values into boolean true/false
  #
  # Only a very limited subset of values are allowed. This method does not try
  # to provide a generic "truthiness" system.
  #
  # @param value [Boolean, Symbol, String]
  # @return [Boolean]
  # @raise
  # @api private
  def self.boolean(value)
    # downcase strings
    if value.respond_to? :downcase
      value = value.downcase
    end

    case value
    when true, :true, 'true', :yes, 'yes'
      true
    when false, :false, 'false', :no, 'no'
      false
    else
      fail('expected a boolean value')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
puppet-3.3.2 lib/puppet/coercion.rb
puppet-3.3.1 lib/puppet/coercion.rb
puppet-3.3.1.rc3 lib/puppet/coercion.rb
puppet-3.3.1.rc2 lib/puppet/coercion.rb
puppet-3.3.1.rc1 lib/puppet/coercion.rb
puppet-3.3.0 lib/puppet/coercion.rb
puppet-3.3.0.rc3 lib/puppet/coercion.rb