lib/picky/categories.rb in picky-2.6.0 vs lib/picky/categories.rb in picky-2.7.0
- old
+ new
@@ -6,10 +6,11 @@
:first,
:map,
:to => :categories
each_delegate :reindex,
+ :each_category,
:to => :categories
# A list of indexed categories.
#
# Options:
@@ -24,36 +25,36 @@
# you only want to match the zipcode, to have the search engine
# display advertisements on the side for the zipcode.
# Nifty! :)
#
def initialize options = {}
- clear
+ clear_categories
@ignore_unassigned_tokens = options[:ignore_unassigned_tokens] || false
end
# Clears both the array of categories and the hash of categories.
#
- def clear
+ def clear_categories
@categories = []
@category_hash = {}
end
+ # Add the given category to the list of categories.
+ #
+ def << category
+ categories << category
+ category_hash[category.name] = category
+ end
+
# Find a given category in the categories.
#
def [] category_name
category_name = category_name.to_sym
category_hash[category_name] || raise_not_found(category_name)
end
def raise_not_found category_name
raise %Q{Index category "#{category_name}" not found. Possible categories: "#{categories.map(&:name).join('", "')}".}
- end
-
- # Add the given category to the list of categories.
- #
- def << category
- categories << category
- category_hash[category.name] = category
end
def to_s
categories.join(', ')
end
\ No newline at end of file