module RiceBubble class Attributes class Array < Base attr_reader :members def initialize(members, &) super(&) @members = instantiate(members) end def valid?(value) return false unless value.respond_to?(:all?) value.all? do |child| members.valid?(child) end end def validate!(_value, coerced:, path:) coerced.each.with_index do |child, index| members.validate!( child, coerced: members.coerce(child), path: "#{path}[#{index}]" ) end end def coerce(value) value.respond_to?(:to_a) ? value.to_a : value end end end end