Module: NomenHelper

Defined in:
app/helpers/nomen_helper.rb

Constant Summary collapse

AVATARS_INDEX =
Rails.root.join('db', 'nomenclatures', 'avatars.yml').freeze
AVATARS =
(AVATARS_INDEX.exist? ? YAML.load_file(AVATARS_INDEX) : {}).freeze

Instance Method Summary collapse

Instance Method Details

#activity_avatar_path(activity) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'app/helpers/nomen_helper.rb', line 11

def activity_avatar_path(activity)
  if (variety = Nomen::Variety.find(activity.cultivation_variety))
    path = item_avatar_path(variety)
  end
  unless path
    path = item_avatar_path Nomen::ActivityFamily.find(activity.family)
  end
  path
end

#item_avatar_path(item) ⇒ Object


5
6
7
8
9
# File 'app/helpers/nomen_helper.rb', line 5

def item_avatar_path(item)
  nomenclature = AVATARS[item.nomenclature.table_name]
  return nil unless nomenclature
  item.rise { |i| nomenclature[i.name] }
end