Module: ActiveRecordExtended::QueryMethods::AnyOf

Defined in:
lib/active_record_extended/query_methods/any_of.rb

Instance Method Summary collapse

Instance Method Details

#any_of(*queries) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/active_record_extended/query_methods/any_of.rb', line 6

def any_of(*queries)
  queries = hash_map_queries(queries)
  build_query(queries) do |arel_query, binds|
    if binds.any?
      @scope.where(unprepared_query(arel_query.to_sql), *binds)
    else
      @scope.where(arel_query)
    end
  end
end

#none_of(*queries) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/active_record_extended/query_methods/any_of.rb', line 17

def none_of(*queries)
  queries = hash_map_queries(queries)
  build_query(queries) do |arel_query, binds|
    if binds.any?
      @scope.where.not(unprepared_query(arel_query.to_sql), *binds)
    else
      @scope.where.not(arel_query)
    end
  end
end