class Axiom::Types::Object
Represents an object type
Public Class Methods
finalize()
click to toggle source
Finalize by setting up a primitive constraint
@return [Class<Axiom::Types::Object>]
@api private
Calls superclass method
# File lib/axiom/types/object.rb, line 34 def self.finalize return self if frozen? inherits_from_primitive super end
infer(object)
click to toggle source
Infer the type of the object
@example
Axiom::Types::Object.infer(::Object) # => Axiom::Types::Object
@param [Object] object
@return [Class<Axiom::Types::Object>]
returned if the type matches
@return [nil]
returned if the type does not match
@api public
Calls superclass method
# File lib/axiom/types/object.rb, line 25 def self.infer(object) super || infer_from_primitive_class(object) end
inspect()
click to toggle source
The type name and primitive
@return [String]
@api public
# File lib/axiom/types/object.rb, line 45 def self.inspect "#{base} (#{primitive})" end
Private Class Methods
infer_from_primitive_class(object)
click to toggle source
Infer the type if the primitive class matches
@param [Object] object
@return [Class<Axiom::Types::Object>]
returned if the primitive class matches
@return [nil]
returned if the primitive class does not match
@api private
# File lib/axiom/types/object.rb, line 59 def self.infer_from_primitive_class(object) self if match_primitive?(object) end
inherits_from_primitive()
click to toggle source
Add a constraint for the primitive
@return [undefined]
@api private
# File lib/axiom/types/object.rb, line 82 def self.inherits_from_primitive constraint(&primitive.method(:===)) end
match_primitive?(object)
click to toggle source
Test if the type matches a primitive class
@param [Object] object
@return [Boolean]
@api private
# File lib/axiom/types/object.rb, line 71 def self.match_primitive?(object) Module === object && (equal?(Object) || object.ancestors.include?(primitive)) end