class Aws::Templates::Processor::Registry
Handler
registry
Handler
registries encapsulate differerent ways of transforming entities into domain-specific output. In nutshell, they are registries of Handler
classes which are able to lookup proper Handler
for a given entity.
Public Instance Methods
[](entity)
click to toggle source
Look-up the handler
# File lib/aws/templates/processor/registry.rb, line 52 def [](entity) return registry[entity] unless entity.is_a?(Module) registry[entity.name] || registry[entity] end
handler_for(entity)
click to toggle source
Try to look-up the handler
# File lib/aws/templates/processor/registry.rb, line 31 def handler_for(entity) handler = self[entity] raise "Handler is not found for #{entity}" unless handler handler.reduce end
include?(k)
click to toggle source
Check if handler exists
# File lib/aws/templates/processor/registry.rb, line 59 def include?(k) !self[k].nil? end
Also aliased as: handler?
keys()
click to toggle source
All possible entity types
# File lib/aws/templates/processor/registry.rb, line 46 def keys registry.keys end
merge(recursive)
click to toggle source
Merge map with another recursive
# File lib/aws/templates/processor/registry.rb, line 39 def merge(recursive) raise "#{recursive} is not recursive" unless Utils.recursive?(recursive) recursive.keys.each { |k| register(k, recursive[k]) } self end
register(entity, handler)
click to toggle source
Register pair entity-handler
Invoked from inside of a Handler
class at definition of the link between the handler class and an entity.
-
entity
- entity the handler claims to be able to process -
handler
- handler class
# File lib/aws/templates/processor/registry.rb, line 25 def register(entity, handler) registry.put_if_absent(_process_entity(entity), handler) end
registry()
click to toggle source
Handler
registry accessor
# File lib/aws/templates/processor/registry.rb, line 14 def registry @registry ||= ::Concurrent::Map.new end
Private Instance Methods
_process_entity(entity)
click to toggle source
# File lib/aws/templates/processor/registry.rb, line 67 def _process_entity(entity) return entity unless entity.is_a?(Module) entity.name || entity.reduce end