Class: Axiom::Types::Hash

Inherits:
Object show all
Defined in:
lib/axiom/types/hash.rb

Overview

Represents a hash type

Class Method Summary collapse

Methods inherited from Object

inspect

Methods inherited from Type

anonymous?, base, constraint, include?, includes, new

Methods included from Options

#accept_options

Class Method Details

.finalizeClass<Axiom::Types::Hash>

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.

Finalize by setting up constraints for the key and value



42
43
44
45
46
47
48
# File 'lib/axiom/types/hash.rb', line 42

def self.finalize
  return self if frozen?
  key_type.finalize
  value_type.finalize
  matches_key_and_value_types
  super
end

.infer(object) ⇒ Class<Axiom::Types::Hash>?

Infer the type of the object

Examples:

type = Axiom::Types.infer(object)

Parameters:

Returns:



28
29
30
31
32
33
34
35
# File 'lib/axiom/types/hash.rb', line 28

def self.infer(object)
  case object
  when primitive
    infer_from_primitive_instance(object)
  else
    super
  end
end