Commit 04fbe1d5cea60b4c3d0d6cb75d02dc05c50d9f86
1 parent
c0d07b65
Exists in
relation
and in
1 other branch
Added type
Showing
2 changed files
with
10 additions
and
0 deletions
Show diff stats
lib/searchkick/relation.rb
... | ... | @@ -363,6 +363,15 @@ module Searchkick |
363 | 363 | self |
364 | 364 | end |
365 | 365 | |
366 | + def type(*args) | |
367 | + spawn.type!(*args) | |
368 | + end | |
369 | + | |
370 | + def type!(*args) | |
371 | + options[:type] = Array(options[:type]) + args.flatten | |
372 | + self | |
373 | + end | |
374 | + | |
366 | 375 | # same as Active Record |
367 | 376 | def inspect |
368 | 377 | entries = results.first(11).map!(&:inspect) | ... | ... |
test/inheritance_test.rb
... | ... | @@ -32,6 +32,7 @@ class InheritanceTest < Minitest::Test |
32 | 32 | store_names ["Green Bear"], Dog |
33 | 33 | store_names ["Blue Bear"], Cat |
34 | 34 | assert_equal ["Blue Bear"], Animal.search("bear", type: [Cat]).map(&:name) |
35 | + assert_equal ["Blue Bear"], Animal.search("bear", relation: true).type(Cat).map(&:name) | |
35 | 36 | end |
36 | 37 | |
37 | 38 | def test_force_multiple_types | ... | ... |