summaryrefslogtreecommitdiff
path: root/app/models/asset_license.rb
blob: ca66d40af63b48d47762b6a0ef3e472116b9f11d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class AssetLicense
  Entry = Struct.new(:key, :url, :requires_attribution, :style, keyword_init: true)

  DICTIONARY = YAML.load_file(Rails.root.join("config", "asset_licenses.yml")).freeze

  def self.keys
    DICTIONARY.keys
  end

  def self.find(key)
    entry = DICTIONARY[key.to_s] if key.present?
    return nil unless entry
    Entry.new(key: key.to_s, url: entry["url"], requires_attribution: entry["requires_attribution"], style: entry["style"])
  end
end