Class: Extant::Coercers::Array
- Defined in:
- lib/extant/coercers/array.rb
Constant Summary
Constants inherited from Base
Class Attribute Summary collapse
-
.value_type ⇒ Object
Returns the value of attribute value_type.
Instance Method Summary collapse
Methods inherited from Base
#coerced?, coercer_name, #initialize
Constructor Details
This class inherits a constructor from Extant::Coercers::Base
Class Attribute Details
.value_type ⇒ Object
Returns the value of attribute value_type.
4 5 6 |
# File 'lib/extant/coercers/array.rb', line 4 def value_type @value_type end |
Instance Method Details
#coerce ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/extant/coercers/array.rb', line 7 def coerce return ArgumentError unless value.respond_to?(:to_a) result = value.to_a return ArgumentError unless result.is_a?(::Array) if value_type result = result.map do |v| coerce_value(v) end end self.coerced = true result rescue ArgumentError UncoercedValue end |