Sha256: 9d74bc062a7f6b57ec7a80401d489308ad601c2dcede9b32ad1e0171d8284ccc
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# -*- encoding : utf-8 -*- require 'search/query_adapter/abstract' module RademadeAdmin module Search module QueryAdapter class ActiveRecord < Abstract protected def where(where_conditions) @values = [] condition = collect_where_conditions(where_conditions) @result.where([condition, *@values]) end def order(order_conditions) order_conditions.each do |order_condition| @result = @result.order(order_condition) end @result end def collect_where_conditions(where_conditions) condition = '' where_conditions.parts.each do |part| condition += " #{where_conditions.type.to_s.capitalize} " unless condition.empty? if part.is_a? RademadeAdmin::Search::Conditions::Where condition += "(#{collect_where_conditions(part)})" else if part[:value].is_a? Array condition += "#{part[:field]} IN (?)" else condition += "#{part[:field]} = ?" end @values << part[:value] end end condition end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rademade_admin-0.0.3 | app/services/search/query_adapter/active_record.rb |
rademade_admin-0.0.2 | app/services/search/query_adapter/active_record.rb |