Class: Fatty::Themes::Registry
- Inherits:
-
Object
- Object
- Fatty::Themes::Registry
- Defined in:
- lib/fatty/themes/registry.rb
Instance Attribute Summary collapse
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #add(defn, source: nil) ⇒ Object
- #clear ⇒ Object
- #each(&block) ⇒ Object
- #fetch(name) ⇒ Object
- #include?(name) ⇒ Boolean
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #names ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
8 9 10 11 |
# File 'lib/fatty/themes/registry.rb', line 8 def initialize @defs = {} @warnings = [] end |
Instance Attribute Details
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
6 7 8 |
# File 'lib/fatty/themes/registry.rb', line 6 def warnings @warnings end |
Instance Method Details
#add(defn, source: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/fatty/themes/registry.rb', line 19 def add(defn, source: nil) name = normalize_name(defn[:name]) if name @defs[name] = defn.merge(name: name, source: source) else warn("Theme missing name#{source_suffix(source)}") end nil end |
#clear ⇒ Object
13 14 15 16 17 |
# File 'lib/fatty/themes/registry.rb', line 13 def clear @defs.clear @warnings.clear nil end |
#each(&block) ⇒ Object
41 42 43 |
# File 'lib/fatty/themes/registry.rb', line 41 def each(&block) @defs.each_value(&block) end |
#fetch(name) ⇒ Object
37 38 39 |
# File 'lib/fatty/themes/registry.rb', line 37 def fetch(name) @defs[normalize_name(name)] end |
#include?(name) ⇒ Boolean
33 34 35 |
# File 'lib/fatty/themes/registry.rb', line 33 def include?(name) @defs.key?(normalize_name(name)) end |
#names ⇒ Object
29 30 31 |
# File 'lib/fatty/themes/registry.rb', line 29 def names @defs.keys end |