app/models/taxon_concept.rb
# Singleton method to fetch the "best available" Hierarchy Entry and store that value.
Singleton method to fetch the "best available" Hierarchy Entry and store that value.
Singleton method to fetch the " best available " Hierarchy Entry and store that value .
def entry(hierarchy = nil)
    @cached_entry ||= {}
    return @cached_entry[hierarchy] if @cached_entry[hierarchy]
    return preferred_entry.hierarchy_entry if preferred_entry_usable?(hierarchy)
    @all_entries ||= HierarchyEntry.sort_by_vetted(
      published_hierarchy_entries.includes(:vetted, :hierarchy))
    if @all_entries.blank?
      @all_entries = HierarchyEntry.sort_by_vetted(
        hierarchy_entries.includes(:vetted, :hierarchy))
    end
    best_entry = hierarchy ?
      @all_entries.detect { |he| he.hierarchy_id == hierarchy.id } || @all_entries.first :
      @all_entries.first
    create_preferred_entry(best_entry) if hierarchy.nil?
    @cached_entry[hierarchy] = best_entry
  end
def entry ( hierarchy = nil ) @cached_entry ||= { } return @cached_entry [ hierarchy ] if @cached_entry [ hierarchy ] return preferred_entry . hierarchy_entry if preferred_entry_usable? ( hierarchy ) @all_entries ||= HierarchyEntry . sort_by_vetted ( published_hierarchy_entries . includes ( :vetted , :hierarchy ) ) if @all_entries . blank? @all_entries = HierarchyEntry . sort_by_vetted ( hierarchy_entries . includes ( :vetted , :hierarchy ) ) end best_entry = hierarchy ? @all_entries . detect { | he | he . hierarchy_id == hierarchy . id } || @all_entries . first : @all_entries . first create_preferred_entry ( best_entry ) if hierarchy . nil? @cached_entry [ hierarchy ] = best_entry end
Singleton method to fetch the "best available" Hierarchy Entry and store that value.
Singleton method to fetch the " best available " Hierarchy Entry and store that value .
hierarchy
<not_specific>