From 974d24a36ab33b9e22e7fd53380c4fb6ce23ec82 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 17 Mar 2020 22:01:22 -0700 Subject: [PATCH] Allow array [skip ci] --- README.md | 2 +- lib/searchkick/relation.rb | 2 +- test/match_test.rb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 769c82f..a48b9a0 100644 --- a/README.md +++ b/README.md @@ -415,7 +415,7 @@ exclude_queries = { "cream" => ["ice cream", "whipped cream"] } -Product.search(query).exclude(*exclude_queries[query]) +Product.search(query).exclude(exclude_queries[query]) ``` You can demote results by boosting by a factor less than one: diff --git a/lib/searchkick/relation.rb b/lib/searchkick/relation.rb index 54fc440..5029047 100644 --- a/lib/searchkick/relation.rb +++ b/lib/searchkick/relation.rb @@ -332,7 +332,7 @@ module Searchkick end def exclude!(*args) - options[:exclude] = Array(options[:exclude]) + args + options[:exclude] = Array(options[:exclude]) + args.flatten self end diff --git a/test/match_test.rb b/test/match_test.rb index 6cad659..237316e 100644 --- a/test/match_test.rb +++ b/test/match_test.rb @@ -176,6 +176,7 @@ class MatchTest < Minitest::Test store_names ["Butter Tub", "Peanut Butter Tub"] assert_search "butter", ["Butter Tub"], exclude: ["peanut butter"] assert_search_relation ["Butter Tub"], Product.search("butter", relation: true).exclude("peanut butter") + assert_search_relation ["Butter Tub"], Product.search("butter", relation: true).exclude(["peanut butter"]) end def test_exclude_butter_word_start -- libgit2 0.21.0