Method: Puppet::Pops::Types::TypeCalculator.infer_callable_methods_t

Defined in:
lib/puppet/pops/types/type_calculator.rb

.infer_callable_methods_t(o) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Infers a type if given object may have callable members, else returns nil. Caller must check for nil or if returned type supports members. This is a much cheaper call than doing a call to the general infer(o) method.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/puppet/pops/types/type_calculator.rb', line 133

def self.infer_callable_methods_t(o)
  # If being a value that cannot have Pcore based methods callable from Puppet Language
  if o.is_a?(String) ||
     o.is_a?(Numeric) ||
     o.is_a?(TrueClass) ||
     o.is_a?(FalseClass) ||
     o.is_a?(Regexp) ||
     o.instance_of?(Array) ||
     o.instance_of?(Hash) ||
     Types::PUndefType::DEFAULT.instance?(o)

    return nil
  end

  # For other objects (e.g. PObjectType instances, and runtime types) full inference needed, since that will
  # cover looking into the runtime type registry.
  #
  infer(o)
end