Files

Axiom::Types::Collection

Represents a collection type

Public Class Methods

finalize() click to toggle source

Finalize by setting up constraints for the member

@return [Class<Axiom::Types::Collection>]

@api private

# File lib/axiom/types/collection.rb, line 56
def self.finalize
  return self if frozen?
  member_type.finalize
  matches_member_type
  super
end
infer(object) click to toggle source

Infer the type of the object

@example with a type

Axiom::Types::Array.infer(Axiom::Types::Array)
# => Axiom::Types::Array

@example with a primitive class

Axiom::Types::Collection.infer(::Array)
# => Axiom::Types::Array

@example with a primitive instance

Axiom::Types::Array.infer(Array[])
# => Axiom::Types::Array

@example with a primitive instance and a member type

Axiom::Types::Collection.infer(Array[Axiom::Types::String])
# => Axiom::Types::Array subclass w/String member type

@example with a primitive instance and a member primitive

Axiom::Types::Collection.infer(Array[String])
# => Axiom::Types::Array subclass w/String member type

@param [Object] object

@return [Class<Axiom::Types::Collection>]

returned if the type matches

@return [nil]

returned if the type does not match

@api public

# File lib/axiom/types/collection.rb, line 42
def self.infer(object)
  case object
  when primitive
    infer_from_primitive_instance(object)
  else
    super
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.