Sha256: 9efd1043247d5fdf8b8372757228533308348d4f869fc23aaf9fe97bf7f15da0
Contents?: true
Size: 960 Bytes
Versions: 23
Compression:
Stored size: 960 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, opts| add_tag(k, opts, true) } end def add_tag(name, opts = nil, is_system = false) 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, is_system) 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, is_system = false) Store.new({ name: name.to_sym, label: name.to_s.titleize, options: opts.to_h, system: is_system }) end end end
Version data entries
23 entries across 23 versions & 1 rubygems