This seems to work:
diff --git a/lib/puppet/pops/types/types.rb b/lib/puppet/pops/types/types.rb |
index ad0c6b375b..2f29745656 100644 |
--- a/lib/puppet/pops/types/types.rb |
+++ b/lib/puppet/pops/types/types.rb |
@@ -1,3 +1,4 @@ |
+# coding: utf-8 |
require_relative 'iterable' |
require_relative 'enumeration' |
require_relative 'recursion_guard' |
@@ -736,7 +737,7 @@ class PScalarDataType < PScalarType |
end |
|
def instance?(o, guard = nil) |
- return o.is_a?(String) || o.is_a?(Integer) || o.is_a?(Float) || o.is_a?(TrueClass) || o.is_a?(FalseClass) |
+ return o.instance_of?(String) || o.is_a?(Integer) || o.instance_of?(Float) || o.instance_of?(TrueClass) || o.instance_of?(FalseClass) |
end |
|
DEFAULT = PScalarDataType.new |
|
And it warns if the serializer is given a subclass of String (or Float, FalseClass, TrueClass). However, I think we need to keep is_a?(Integer) since it is subclassed by Fixnum and Bignum, and those weren't unified until ruby 2.4. Also I'd expect instance_of? to be faster since it doesn't need to walk the class hierarchy of the passed in object o. |