Sha256: 22e59debed446e88307bb5452ade9863a97db5a42a3cd27846de85bc40bde48f
Contents?: true
Size: 784 Bytes
Versions: 5
Compression:
Stored size: 784 Bytes
Contents
module Ardm module Ar module PredicateBuilder class ArrayHandler # :nodoc: def call(attribute, value) if value.include?(nil) values = value.compact if values.length == 0 attribute.eq(nil) else call(attribute, values).or(attribute.eq(nil)) end else values = value.map { |x| x.is_a?(::ActiveRecord::Base) ? x.id : x } ranges, values = values.partition { |v| v.is_a?(::Range) } array_predicates = ranges.map { |range| attribute.in(range) } array_predicates << attribute.in(values) array_predicates.inject { |composite, predicate| composite.or(predicate) } end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems