Although the context is likely irrelevant, I'm using the Chewy gem to filter Elasticsearch results using this code:
scope = scope.filter {
(send('facet_properties').send(property_ids[0], :or) == val.map(&:to_i)) |
(send('facet_properties').send(property_ids[1], :or) == val.map(&:to_i))
}
I'm looking for a way to loop through each element in property_ids
rather than calling property_ids[0]
, property_ids[1]
, etc., separated by an or
individually. In actual use property_ids
will not be a fixed length.