Sha256: b7b5e51bfb19f00840543a0e80d9836a006909d058b2bd63256fb29660dde664
Contents?: true
Size: 922 Bytes
Versions: 5
Compression:
Stored size: 922 Bytes
Contents
module DynamicSunspotSearch module Translator module With def self.apply(query_object, with_scope) return unless with_scope.present? query_object.tap do |search| case with_scope when Array return with_scope.map do |filter| apply(search, filter) end when Hash return with_scope.map do |key, value| case value when Hash value.map do |method, args| search.with(key).send(method, *Array.wrap(args)) end when /^range:.+\.\..+$/ range_start, range_end = value.match(/^range:(.+)\.\.(.+)$/).values_at(1, 2) search.with(key, (range_start..range_end)) else search.with(key, value) end end end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems