Sha256: 3a2ed1e2a81d50a93f5d86bd78aa70628b338217a9a4caeab8fa62d1536046c2
Contents?: true
Size: 994 Bytes
Versions: 34
Compression:
Stored size: 994 Bytes
Contents
module Workarea class ProductPrimaryNavigation def initialize(product, options = {}) @product = product @options = options end def name if main_nav_taxon.present? main_nav_taxon.name elsif oldest_category.present? oldest_category.name else '' end end def main_nav_taxon return nil unless highest_category.try(:taxon).try(:ancestors).present? highest_category.taxon.ancestors_and_self.second end def highest_category @highest_category ||= categories .select { |c| c.taxon.present? } .sort { |a, b| a.taxon.depth <=> b.taxon.depth } .first end def oldest_category categories.sort { |a, b| a.created_at <=> b.created_at }.first end private def categories @categories ||= @options[:categories] || Categorization.new(@product).to_models end end end
Version data entries
34 entries across 34 versions & 1 rubygems