Class: Appydave::Tools::Types::ArrayType
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- Appydave::Tools::Types::ArrayType
- Defined in:
- lib/appydave/tools/types/array_type.rb
Overview
Used by the ActiveModel attributes API to cast values to arrays
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/appydave/tools/types/array_type.rb', line 8 def cast(value) case value when String value.split(',') when Array value else raise ArgumentError, "Cannot cast #{value.class} to Array" end end |
#serialize(value) ⇒ Object
19 20 21 |
# File 'lib/appydave/tools/types/array_type.rb', line 19 def serialize(value) value.join(',') end |