lib/picky/query/allocation.rb in picky-3.0.1 vs lib/picky/query/allocation.rb in picky-3.1.0

- old
+ new

@@ -5,17 +5,22 @@ # An allocation has a number of combinations: # [token, index] [other_token, other_index], ... # class Allocation # :nodoc:all - attr_reader :count, :ids, :score, :combinations, :result_identifier + attr_reader :count, + :ids, + :score, + :combinations, + :result_identifier # # - def initialize combinations, result_identifier + def initialize index, combinations @combinations = combinations - @result_identifier = result_identifier + @result_identifier = index.result_identifier # TODO Make cleverer. + @backend = index.backend # TODO Make cleverer. end def hash @combinations.hash end @@ -28,13 +33,13 @@ # def calculate_score weights @score ||= @combinations.calculate_score(weights) end - # Asks the combinations for the (intersected) ids. + # Asks the backend for the (intersected) ids. # def calculate_ids amount, offset - @combinations.ids amount, offset # Calculate as many ids as are necessary. + @backend.ids combinations, amount, offset end # This starts the searching process. # def process! amount, offset \ No newline at end of file