Class: Gyroscope::IntegerList

Inherits:
Virtus::Attribute
  • Object
show all
Defined in:
lib/gyroscope/integer_list.rb

Instance Method Summary collapse

Instance Method Details

#coerce(values) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/gyroscope/integer_list.rb', line 6

def coerce(values)
  return nil if values.nil?

  attr = Virtus::Attribute.build Integer, strict: true
  Array(values).
    map {|value| value.respond_to?(:split) ? value.split(',') : value }.
    flatten.
    map { |v| attr.coerce(v) }
end