Class: SparkleFormation::Registry
- Inherits:
-
Object
- Object
- SparkleFormation::Registry
- Defined in:
- lib/sparkle_formation/utils.rb
Overview
Registry helper
Class Method Summary collapse
-
.init! ⇒ self
Initialize registry.
-
.insert(name, location, *args) ⇒ Object
Insert registry item into context.
-
.register(name) { ... } ⇒ Object
Register block.
Class Method Details
.init! ⇒ self
Initialize registry
72 73 74 75 |
# File 'lib/sparkle_formation/utils.rb', line 72 def init! @register = AttributeStruct.hashish.new self end |
.insert(name, location, *args) ⇒ Object
Insert registry item into context
90 91 92 93 94 95 96 |
# File 'lib/sparkle_formation/utils.rb', line 90 def insert(name, location, *args) if block = @register[name] location.instance_exec(*args, &block) else raise KeyError.new("Requested item not found in registry (#{name})") end end |
.register(name) { ... } ⇒ Object
Register block
81 82 83 |
# File 'lib/sparkle_formation/utils.rb', line 81 def register(name, &block) @register[name] = block end |