Class: T::Types::TypedHash::Untyped

Inherits:
T::Types::TypedHash show all
Defined in:
lib/types/types/typed_hash.rb

Defined Under Namespace

Modules: Private

Instance Method Summary collapse

Methods inherited from T::Types::TypedHash

#keys, #name, #new, #recursively_valid?, #type, #underlying_class, #values

Methods inherited from T::Types::TypedEnumerable

#build_type, #describe_obj, #name, #recursively_valid?, #type, #underlying_class

Methods inherited from Base

#==, #describe_obj, #error_message_for_obj, #error_message_for_obj_recursive, #hash, method_added, #recursively_valid?, #subtype_of?, #to_s, #validate!

Constructor Details

#initializeUntyped

Returns a new instance of Untyped.



49
50
51
52
53
# File 'lib/types/types/typed_hash.rb', line 49

def initialize
  # Use the INSTANCE constant directly (rather than `T.untyped`) so this
  # can be built at load time, mirroring TypedArray::Untyped.
  super(keys: T::Types::Untyped::Private::INSTANCE, values: T::Types::Untyped::Private::INSTANCE)
end

Instance Method Details

#freezeObject



59
60
61
62
# File 'lib/types/types/typed_hash.rb', line 59

def freeze
  build_type # force lazy initialization before freezing the object
  super
end

#valid?(obj) ⇒ Boolean

Returns:



55
56
57
# File 'lib/types/types/typed_hash.rb', line 55

def valid?(obj)
  obj.is_a?(Hash)
end