Puppet Function: is_a
- Defined in:
- lib/puppet/functions/is_a.rb
- Function type:
- Ruby 4.x API
Summary
Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks.Overview
See the documentation for “The Puppet Type System” for more information about types. See the ‘assert_type()` function for flexible ways to assert the type of a value.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/puppet/functions/is_a.rb', line 26 Puppet::Functions.create_function(:is_a) do # @param value # The value to be checked # # @param type # The expected type # # @return [Boolean] # Return's `true` or `false`. dispatch :is_a do param 'Any', :value param 'Type', :type end def is_a(value, type) # rubocop:disable Naming/PredicateName : Used in to many other places to rename at this time, attempting to refactor caused Rubocop to crash. # See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression Puppet::Pops::Types::TypeCalculator.instance?(type, value) end end |