2 # Boolean check to determine whether a variable is of a given data type.
3 # This is equivalent to the `=~` type checks.
5 # @example Example Usage:
11 # if $foo.is_a(Integer) {
14 # if $bar.is_a(Array) {
17 # if $baz.is_a(String) {
21 # See the documentation for "The Puppet Type System" for more information about types.
22 # See the `assert_type()` function for flexible ways to assert the type of a value.
24 Puppet::Functions.create_function(:is_a) do
26 # The value to be checked
32 # Return's `true` or `false`.
38 def is_a(value, type) # rubocop:disable Style/PredicateName : Used in to many other places to rename at this time, attempting to refactor caused Rubocop to crash.
39 # See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression
40 Puppet::Pops::Types::TypeCalculator.instance?(type, value)