Sha256: 83d389b92c5298944a27ee07ecd402161fc8f85c38c194ed1f187190adb41514

Contents?: true

Size: 814 Bytes

Versions: 20

Compression:

Stored size: 814 Bytes

Contents

# Returns the type when passed a value.
#
# @example how to compare values' types
#   # compare the types of two values
#   if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") }
# @example how to compare against an abstract type
#   unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") }
#   unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") }
#
# 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.
#
Puppet::Functions.create_function(:type_of) do
  def type_of(value)
    Puppet::Pops::Types::TypeCalculator.infer_set(value)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-retrospec-1.8.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.7.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.6.1 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.6.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.5.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.4.1 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.4.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.3.2 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.3.1 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.3.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.2.1 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.2.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.1.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-1.0.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-0.12.1 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-0.12.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-0.11.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-0.10.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-0.9.1 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb
puppet-retrospec-0.9.0 spec/fixtures/modules/stdlib/lib/puppet/functions/type_of.rb