Method: Puppet::Pops::Types::PStructType#instance?
- Defined in:
- lib/puppet/pops/types/types.rb
#instance?(o, guard = nil) ⇒ Boolean
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 |
# File 'lib/puppet/pops/types/types.rb', line 1981 def instance?(o, guard = nil) # The inferred type of a class derived from Hash is either Runtime or Object. It's not assignable to the Struct type. return false unless o.instance_of?(Hash) matched = 0 @elements.all? do |e| key = e.name v = o[key] if v.nil? && !o.include?(key) # Entry is missing. Only OK when key is optional e.key_type.assignable?(PUndefType::DEFAULT, guard) else matched += 1 e.value_type.instance?(v, guard) end end && matched == o.size end |