class SmartAleck::CategoryIndexer

Attributes

category_hash[R]

Public Class Methods

index(categories) click to toggle source
# File lib/smart_aleck/category_indexer.rb, line 7
def self.index(categories)
  new(categories).category_hash
end
new(categories) click to toggle source
# File lib/smart_aleck/category_indexer.rb, line 11
def initialize(categories)
  @category_hash =
    Base58.encode(
      categories.map {|category|
        2 ** (category.respond_to?(:id) ? category.id : category).to_i
      }.inject(:|).to_i
    )
end