Class: Yarrow::Schema::Types::List
- Defined in:
- lib/yarrow/schema/types.rb
Instance Attribute Summary collapse
-
#element_type ⇒ Object
readonly
Returns the value of attribute element_type.
Attributes inherited from TypeClass
Class Method Summary collapse
Instance Method Summary collapse
- #accept_elements(accept_type) ⇒ Object
- #check(input) ⇒ Object
-
#initialize(unit_type, element_type) ⇒ List
constructor
A new instance of List.
Methods inherited from TypeClass
#accept, #cast, #check_instance_of!, #check_kind_of!, #check_respond_to_all!, #check_respond_to_any!, #coerce, #should_coerce?, #|
Constructor Details
#initialize(unit_type, element_type) ⇒ List
Returns a new instance of List.
180 181 182 183 |
# File 'lib/yarrow/schema/types.rb', line 180 def initialize(unit_type, element_type) @element_type = element_type super(unit_type) end |
Instance Attribute Details
#element_type ⇒ Object (readonly)
Returns the value of attribute element_type.
177 178 179 |
# File 'lib/yarrow/schema/types.rb', line 177 def element_type @element_type end |
Class Method Details
Instance Method Details
#accept_elements(accept_type) ⇒ Object
185 186 187 188 |
# File 'lib/yarrow/schema/types.rb', line 185 def accept_elements(accept_type) element_type.accept(accept_type) self end |
#check(input) ⇒ Object
190 191 192 193 194 195 196 |
# File 'lib/yarrow/schema/types.rb', line 190 def check(input) converted = container_type.cast(input) converted.map do |item| element_type.cast(item) end end |