class SparkleFormation::Registry
Registry
helper
Public Class Methods
init!()
click to toggle source
Initialize registry
@return [self]
# File lib/sparkle_formation/utils.rb, line 72 def init! @register = AttributeStruct.hashish.new self end
insert(name, location, *args)
click to toggle source
Insert registry item into context
@param name [String, Symbol] name of item @param location [AttributeStruct] context to apply block @param args [Object] argument list for block
# 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, &block)
click to toggle source
Register block
@param name [String, Symbol] name of item @yield block to register
# File lib/sparkle_formation/utils.rb, line 81 def register(name, &block) @register[name] = block end