app/models/solidus/elastic_product/serializer.rb
# The exact same as taxon.ancestors only all the taxons and determined once
# and cached. After that it is just a lookup.
The exact same as taxon.ancestors only all the taxons and determined once
and cached. After that it is just a lookup.
The exact same as taxon . ancestors only all the taxons and determined once and cached . After that it is just a lookup .
def self_and_ancestors requested_taxon
          @ancestors_by_taxon ||= begin
            all.inject({}) do |hsh, taxon|
              taxon_id = taxon.id
              hsh[taxon_id] = [taxon]
              begin
                parent = by_id[taxon.parent_id]
                hsh[taxon_id] << parent if parent
              end until (taxon = parent).nil?
              hsh[taxon_id]
              hsh
            end
          end
          @ancestors_by_taxon[requested_taxon.id].reverse
        end
def self_and_ancestors requested_taxon @ancestors_by_taxon ||= begin all . inject ( { } ) do | hsh , taxon | taxon_id = taxon . id hsh [ taxon_id ] = [ taxon ] begin parent = by_id [ taxon . parent_id ] hsh [ taxon_id ] << parent if parent end until ( taxon = parent ) . nil? hsh [ taxon_id ] hsh end end @ancestors_by_taxon [ requested_taxon . id ] . reverse end
The exact same as taxon.ancestors only all the taxons and determined once
and cached.
The exact same as taxon . ancestors only all the taxons and determined once and cached .
requested_taxon