Class: T::Types::TypedHash
- Inherits:
-
TypedEnumerable
- Object
- Base
- TypedEnumerable
- T::Types::TypedHash
- Defined in:
- lib/types/types/typed_hash.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Untyped
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Technically we don’t need these, but they are a nice api.
-
#values ⇒ Object
readonly
Technically we don’t need these, but they are a nice api.
Attributes inherited from TypedEnumerable
Instance Method Summary collapse
-
#initialize(keys:, values:) ⇒ TypedHash
constructor
A new instance of TypedHash.
-
#name ⇒ Object
overrides Base.
- #new(*args, &blk) ⇒ Object
-
#recursively_valid?(obj) ⇒ Boolean
overrides Base.
- #underlying_class ⇒ Object
-
#valid?(obj) ⇒ Boolean
overrides Base.
Methods inherited from TypedEnumerable
Methods inherited from Base
#==, #describe_obj, #error_message_for_obj, #error_message_for_obj_recursive, #hash, method_added, #subtype_of?, #to_s, #validate!
Constructor Details
Instance Attribute Details
#keys ⇒ Object (readonly)
Technically we don’t need these, but they are a nice api
7 8 9 |
# File 'lib/types/types/typed_hash.rb', line 7 def keys @keys end |
#values ⇒ Object (readonly)
Technically we don’t need these, but they are a nice api
7 8 9 |
# File 'lib/types/types/typed_hash.rb', line 7 def values @values end |
Instance Method Details
#name ⇒ Object
overrides Base
20 21 22 |
# File 'lib/types/types/typed_hash.rb', line 20 def name "T::Hash[#{@keys.name}, #{@values.name}]" end |
#new(*args, &blk) ⇒ Object
34 35 36 |
# File 'lib/types/types/typed_hash.rb', line 34 def new(*args, &blk) Hash.new(*T.unsafe(args), &blk) end |
#recursively_valid?(obj) ⇒ Boolean
overrides Base
25 26 27 |
# File 'lib/types/types/typed_hash.rb', line 25 def recursively_valid?(obj) obj.is_a?(Hash) && super end |
#underlying_class ⇒ Object
9 10 11 |
# File 'lib/types/types/typed_hash.rb', line 9 def Hash end |