Module: Puppet::Coercion Private
- Defined in:
- lib/puppet/coercion.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Various methods used to coerce values into a canonical form.
Class Method Summary collapse
-
.boolean(value) ⇒ Boolean
private
Try to coerce various input values into boolean true/false.
-
.boolean_values ⇒ Array
private
Return the list of acceptable boolean values.
Class Method Details
.boolean(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/puppet/coercion.rb', line 16 def self.boolean(value) # downcase strings if value.respond_to? :downcase value = value.downcase end case value when true, :true, 'true', :yes, 'yes' # rubocop:disable Lint/BooleanSymbol true when false, :false, 'false', :no, 'no' # rubocop:disable Lint/BooleanSymbol false else fail('expected a boolean value') end end |
.boolean_values ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the list of acceptable boolean values.
This is limited to lower-case, even though boolean() is case-insensitive.
39 40 41 |
# File 'lib/puppet/coercion.rb', line 39 def self.boolean_values %w[true false yes no] end |