Module: Warren::Handler

Defined in:
lib/warren/handler.rb,
lib/warren/handler/log.rb,
lib/warren/handler/base.rb,
lib/warren/handler/test.rb,
lib/warren/handler/broadcast.rb

Overview

A Handler provides an interface for sending messages to either a message queue, a log, or an internal store for testing purposes.

Defined Under Namespace

Classes: Base, Broadcast, Log, Test

Class Method Summary collapse

Class Method Details

.routing_key_template(prefix) ⇒ String

Generates a template for routing keys for the given prefix, or a template that returns the provided routing key if no prefix is supplied.

Examples:

With a prefix

template = Warren::Handler.routing_key_template('example') # => 'example.%s'
format(template, 'routing.key') #=> 'example.routing.key'

Without a prefix

template = Warren::Handler.routing_key_template(nil) # => '%s'
format(template, 'routing.key') #=> 'routing.key'

Parameters:

  • prefix (String, nil)

    The prefix to use in the template

Returns:

  • (String)

    A template for generating routing keys



26
27
28
# File 'lib/warren/handler.rb', line 26

def self.routing_key_template(prefix)
  prefix ? "#{prefix}.%s" : '%s'
end