Module: Puppet::Pops::Types::TypeAsserter
- Defined in:
- lib/puppet/pops/types/type_asserter.rb
Class Method Summary collapse
-
.assert_assignable(subject, expected_type, type_to_check) ⇒ Object
Asserts that a type_to_check is assignable to required_type and raises a Puppet::ParseError if that’s not the case.
-
.assert_instance_of(subject, expected_type, value, nil_ok = false) ⇒ Object
Asserts that a value is an instance of a given type and raises a Puppet::ParseError if that’s not the case.
Class Method Details
.assert_assignable(subject, expected_type, type_to_check) ⇒ Object
Asserts that a type_to_check is assignable to required_type and raises a Puppet::ParseError if that’s not the case
14 15 16 17 |
# File 'lib/puppet/pops/types/type_asserter.rb', line 14 def self.assert_assignable(subject, expected_type, type_to_check) report_type_mismatch(subject, expected_type, type_to_check) unless expected_type.assignable?(type_to_check) type_to_check end |
.assert_instance_of(subject, expected_type, value, nil_ok = false) ⇒ Object
Asserts that a value is an instance of a given type and raises a Puppet::ParseError if that’s not the case
29 30 31 32 33 34 |
# File 'lib/puppet/pops/types/type_asserter.rb', line 29 def self.assert_instance_of(subject, expected_type, value, nil_ok = false) unless value.nil? && nil_ok report_type_mismatch(subject, expected_type, TypeCalculator.singleton.infer_set(value).generalize) unless expected_type.instance?(value) end value end |