Commit 1993313e by liyijie

feat: 支持cont_any的设置

parent 1700a25f
module RansackMongo module RansackMongo
class MongoAdapter class MongoAdapter
PREDICATES = %w[null not_null eq not_eq cont in start mstart gt lt gteq lteq] PREDICATES = %w[null not_null eq not_eq cont cont_any in start mstart gt lt gteq lteq]
def initialize def initialize
@query = {} @query = {}
...@@ -26,6 +26,11 @@ module RansackMongo ...@@ -26,6 +26,11 @@ module RansackMongo
@query[attr] = { '$ne' => value } @query[attr] = { '$ne' => value }
end end
def cont_any_matcher(attr, value_arr)
value = Array(value_arr).join('|')
cont_matcher(attr, value)
end
def cont_matcher(attr, value) def cont_matcher(attr, value)
@query[attr] = /#{value}/i @query[attr] = /#{value}/i
end end
......
...@@ -5,7 +5,6 @@ module RansackMongo ...@@ -5,7 +5,6 @@ module RansackMongo
end end
def parse(params) def parse(params)
binding.pry
(params || {}).keys.inject({}) do |query, query_param| (params || {}).keys.inject({}) do |query, query_param|
attr = query_param.to_s attr = query_param.to_s
p, attr = detect_and_strip_from_string(attr) p, attr = detect_and_strip_from_string(attr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment