Class: Glia::UpdateRegistry
- Inherits:
-
Object
- Object
- Glia::UpdateRegistry
- Defined in:
- lib/glia/update_registry.rb
Class Method Summary collapse
- .area(area_code, theme = :default, &blk) ⇒ Object
- .clear(area_code = nil) ⇒ Object
- .merge_themes(area_code, theme_inheritance = nil) ⇒ Object
Class Method Details
.area(area_code, theme = :default, &blk) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/glia/update_registry.rb', line 4 def area(area_code, theme = :default, &blk) #@todo UpdateRegistry can load update_data from cache and instantiate new UpdateBuilder directly with cached data. @updates ||= {} @updates[area_code] ||= {} update = @updates[area_code][theme] ||= UpdateBuilder.new if block_given? update.instance_eval(&blk) end update end |
.clear(area_code = nil) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/glia/update_registry.rb', line 25 def clear(area_code = nil) if area_code.nil? @updates = {} else @updates.delete(area_code) end self end |
.merge_themes(area_code, theme_inheritance = nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/glia/update_registry.rb', line 16 def merge_themes(area_code, theme_inheritance = nil) theme_inheritance ||= [:default] merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } data = theme_inheritance.each_with_object({}) do |theme, data| data.merge!(area(area_code, theme).to_h, &merger) end UpdateBuilder.new(data) end |