Module: Aws::Templates::Processor
- Includes:
- Routing
- Defined in:
- lib/aws/templates/processor.rb,
lib/aws/templates/processor/handler.rb,
lib/aws/templates/processor/routing.rb,
lib/aws/templates/processor/registry.rb
Overview
Abstract processor
Processors are used in artifacts rendering and help generators. Processor embodies functionality required to register an entity handler and look-up the registry when the entity is processed.
Defined Under Namespace
Modules: Routing Classes: Handler, Registry
Instance Method Summary collapse
-
#define_handler(entity, handler, &blk) ⇒ Object
Define handler for entity.
-
#handler?(*args) ⇒ Boolean
Proxy for Registry handler? method.
-
#handler_for(*args) ⇒ Object
Proxy for Registry handler_for method.
-
#process(_entity, _params = nil) ⇒ Object
Handlder look-up logic.
-
#routing(routes) ⇒ Object
Add handlers.
Methods included from Routing
Instance Method Details
#define_handler(entity, handler, &blk) ⇒ Object
Define handler for entity
Another way to define handlers for entities. Creates anonymous class and attaches as the handler to the specified entity.
39 40 41 |
# File 'lib/aws/templates/processor.rb', line 39 def define_handler(entity, handler, &blk) Class.new(handler, &blk).register_in(self).for_entity(entity) end |
#handler?(*args) ⇒ Boolean
Proxy for Registry handler? method
22 23 24 |
# File 'lib/aws/templates/processor.rb', line 22 def handler?(*args) registry.handler?(*args) end |
#handler_for(*args) ⇒ Object
Proxy for Registry handler_for method
16 17 18 |
# File 'lib/aws/templates/processor.rb', line 16 def handler_for(*args) registry.handler_for(*args) end |
#process(_entity, _params = nil) ⇒ Object
Handlder look-up logic.
Should provide logic for processing entities.
30 31 32 |
# File 'lib/aws/templates/processor.rb', line 30 def process(_entity, _params = nil) raise Templates::Exception::NotImplementedError.new('The method should be overriden') end |
#routing(routes) ⇒ Object
Add handlers
Add routing between handlers and correspondent entities from another entity which supports routing concept.
48 49 50 |
# File 'lib/aws/templates/processor.rb', line 48 def routing(routes) registry.merge(routes.registry) end |