Class: Dbee::Providers::ActiveRecordProvider::Makers::Where
- Inherits:
-
Object
- Object
- Dbee::Providers::ActiveRecordProvider::Makers::Where
- Includes:
- Singleton
- Defined in:
- lib/dbee/providers/active_record_provider/makers/where.rb
Overview
Derives Arel#where predicates.
Instance Method Summary collapse
Instance Method Details
#make(filter, arel_column) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dbee/providers/active_record_provider/makers/where.rb', line 18 def make(filter, arel_column) # If the filter has a value of nil, then simply return an IS (NOT) NULL predicate return make_is_null_predicate(arel_column, filter.class) if filter.value.nil? values = Array(filter.value).flatten # This logic helps ensure that if a null exists that it translates to an IS NULL # predicate and does not get put into an in or not_in clause. predicates = if values.include?(nil) [make_is_null_predicate(arel_column, filter.class)] else [] end predicates += make_predicates(filter, arel_column, values - [nil]) # Chain all predicates together predicates.inject(predicates.shift) do |memo, predicate| memo.or(predicate) end end |