lib/picky/indexed/category.rb in picky-1.2.2 vs lib/picky/indexed/category.rb in picky-1.2.3
- old
+ new
@@ -5,22 +5,26 @@
# For example an index category for names holds a exact and
# a partial index bundle for names.
#
class Category
- attr_accessor :exact, :partial
+ attr_accessor :exact
attr_reader :identifier, :name
+ attr_writer :partial
#
#
def initialize name, index, options = {}
@name = name
configuration = Configuration::Index.new index, self
@identifier = configuration.identifier
+ # TODO Push the defaults out into the index.
+ #
+ @partial_strategy = options[:partial] || Cacher::Partial::Default
similarity = options[:similarity] || Cacher::Similarity::Default
@exact = options[:exact_index_bundle] || Bundle.new(:exact, configuration, similarity)
@partial = options[:partial_index_bundle] || Bundle.new(:partial, configuration, similarity)
@@ -60,9 +64,15 @@
# Returns the right index bundle for this token.
#
def bundle_for token
token.partial? ? partial : exact
+ end
+
+ # The partial strategy defines whether to really use the partial index.
+ #
+ def partial
+ @partial_strategy.use_exact_for_partial?? @exact : @partial
end
#
#
def combination_for token
\ No newline at end of file