Module: Picky::API::Search::Boost

Included in:
Search
Defined in:
lib/picky/api/search/boost.rb

Instance Method Summary collapse

Instance Method Details

#extract_boosts(thing) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/picky/api/search/boost.rb', line 7

def extract_boosts thing
  if thing.respond_to?(:boost_for)
    thing
  else
    if thing.respond_to?(:[])
      Query::Boosts.new thing
    else
      raise "boost options for a Search should be either\n* for example a Hash { [:name, :surname] => +3 }\nor\n* an object that responds to #boost_for(combinations) and returns a boost float\n"
    end
  end
end