Class: SparkleFormation::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkle_formation/utils.rb

Overview

Registry helper

Class Method Summary collapse

Class Method Details

.init!self

Initialize registry



76
77
78
79
# File 'lib/sparkle_formation/utils.rb', line 76

def init!
  @register = AttributeStruct.hashish.new
  self
end

.insert(name, location, *args) ⇒ Object

Insert registry item into context



94
95
96
97
98
99
100
# File 'lib/sparkle_formation/utils.rb', line 94

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

Yields:

  • block to register



85
86
87
# File 'lib/sparkle_formation/utils.rb', line 85

def register(name, &block)
  @register[name] = block
end