Class: API::Validations::Types::CommaSeparatedToArray
- Inherits:
-
Object
- Object
- API::Validations::Types::CommaSeparatedToArray
show all
- Defined in:
- lib/api/validations/types/comma_separated_to_array.rb
Class Method Summary
collapse
Class Method Details
.coerce ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/api/validations/types/comma_separated_to_array.rb', line 7
def self.coerce
lambda do |value|
case value
when String
value.split(',').map(&:strip)
when Array
value.flat_map { |v| v.to_s.split(',').map(&:strip) }
else
[]
end
end
end
|