Class: TypedData::Schema::MapType
- Inherits:
-
Type
- Object
- Type
- TypedData::Schema::MapType
show all
- Defined in:
- lib/typed_data/schema/map_type.rb
Constant Summary
Constants inherited
from Type
Type::SUPPORTED_LOGICAL_TYPES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(types) ⇒ MapType
Returns a new instance of MapType.
9
10
11
|
# File 'lib/typed_data/schema/map_type.rb', line 9
def initialize(types)
@element_type = Schema.build_type(types)
end
|
Instance Attribute Details
#element_type ⇒ Object
Returns the value of attribute element_type.
6
7
8
|
# File 'lib/typed_data/schema/map_type.rb', line 6
def element_type
@element_type
end
|
Instance Method Details
#accept(visitor, value) ⇒ Object
13
14
15
|
# File 'lib/typed_data/schema/map_type.rb', line 13
def accept(visitor, value)
visitor.visit_map(self, value)
end
|
#match?(value) ⇒ Boolean
25
26
27
|
# File 'lib/typed_data/schema/map_type.rb', line 25
def match?(value)
value.is_a?(Hash) && value.all? { |_, v| @element_type.match?(v) }
end
|
#primitive? ⇒ Boolean
21
22
23
|
# File 'lib/typed_data/schema/map_type.rb', line 21
def primitive?
false
end
|
#to_s ⇒ Object
17
18
19
|
# File 'lib/typed_data/schema/map_type.rb', line 17
def to_s
"map_#{@element_type}"
end
|