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,6 +363,15 @@ module Searchkick | ||
363 | self | 363 | self |
364 | end | 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 | # same as Active Record | 375 | # same as Active Record |
367 | def inspect | 376 | def inspect |
368 | entries = results.first(11).map!(&:inspect) | 377 | entries = results.first(11).map!(&:inspect) |
test/inheritance_test.rb
@@ -32,6 +32,7 @@ class InheritanceTest < Minitest::Test | @@ -32,6 +32,7 @@ class InheritanceTest < Minitest::Test | ||
32 | store_names ["Green Bear"], Dog | 32 | store_names ["Green Bear"], Dog |
33 | store_names ["Blue Bear"], Cat | 33 | store_names ["Blue Bear"], Cat |
34 | assert_equal ["Blue Bear"], Animal.search("bear", type: [Cat]).map(&:name) | 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 | end | 36 | end |
36 | 37 | ||
37 | def test_force_multiple_types | 38 | def test_force_multiple_types |