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
54 55 56 57 |
# File 'lib/sparkle_formation/utils.rb', line 54 def init! @register = AttributeStruct.hashish.new self end |
.insert(name, location, *args) ⇒ Object
Insert registry item into context
72 73 74 75 76 77 78 |
# File 'lib/sparkle_formation/utils.rb', line 72 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
63 64 65 |
# File 'lib/sparkle_formation/utils.rb', line 63 def register(name, &block) @register[name] = block end |