Sha256: 8085e56c94f77305d37af8e0906e5b60df78ae87eb1a74ad1c51caf8f82cdeb6
Contents?: true
Size: 872 Bytes
Versions: 21
Compression:
Stored size: 872 Bytes
Contents
module Lookbook class TagStore CONFIG_FILE = "config/tags.yml" attr_reader :store delegate :to_h, to: :store def initialize(config = nil) @store = {} config.to_h.each { |k, v| add_tag(k, v) } end def add_tag(name, opts = nil) name = name.to_sym if store.key?(name) raise ConfigError.new("tag with name '#{name}' already exists", scope: "tags.config") else store[name] = build_config(name, opts) end end def get_tag(name) store[name.to_sym] end def self.init_from_config new(default_config) end def self.default_config ConfigLoader.call(CONFIG_FILE) end protected def build_config(name, opts = nil) Store.new({ name: name.to_sym, label: name.to_s.titleize, options: opts.to_h }) end end end
Version data entries
21 entries across 21 versions & 1 rubygems