lib/picky/bundle_realtime.rb in picky-3.6.16 vs lib/picky/bundle_realtime.rb in picky-4.0.0pre1
- old
+ new
@@ -45,12 +45,10 @@
else
# Update the realtime index.
#
str_or_syms << str_or_sym
- # TODO Introduce a new method?
- #
ids = @inverted[str_or_sym] ||= []
ids.send where, id
end
# Weights.
@@ -66,20 +64,22 @@
ids
end
# Add string/symbol to similarity index.
#
- # TODO Probably where makes no sense here. Should have its own order.
- #
def add_similarity str_or_sym, where = :unshift
if encoded = self.similarity_strategy.encoded(str_or_sym)
similars = @similarity[encoded] ||= []
# Not completely correct, as others will also be affected, but meh.
#
similars.delete str_or_sym if similars.include? str_or_sym
- similars.send where, str_or_sym
+ similars << str_or_sym
+
+ # Uses the sort order of the strategy.
+ #
+ self.similarity_strategy.sort similars, str_or_sym
end
end
# Partializes the text and then adds each.
#
@@ -89,12 +89,13 @@
end
end
# Builds the realtime mapping.
#
- # Note: Experimental feature.
+ # Note: Experimental feature. Might be removed in 4.0.
#
- # TODO Subset of #add. Rewrite.
+ # TODO Subset of #add. Rewrite, optimize.
+ # THINK Maybe load it and just replace the arrays with the corresponding ones.
#
def build_realtime
clear_realtime
@inverted.each_pair do |str_or_sym, ids|
ids.each do |id|