class Msgr::Route

Constants

MATCH_REGEXP

Attributes

action[R]
consumer[R]
opts[R]

Public Class Methods

new(key, opts = {}) click to toggle source
# File lib/msgr/route.rb, line 8
def initialize(key, opts = {})
  @opts = opts
  raise ArgumentError.new 'Missing `to` options.' unless @opts[:to]

  add key

  result = MATCH_REGEXP.match(opts[:to].strip.to_s)

  unless result
    raise ArgumentError.new \
      "Invalid consumer format: #{opts[:to].strip.to_s.inspect}. " \
      'Must be `consumer_class#action`.'
  end

  @consumer = "#{result[:consumer].camelize}Consumer"
  @action   = result[:action].underscore
end

Public Instance Methods

accept?(_key, opts) click to toggle source
# File lib/msgr/route.rb, line 41
def accept?(_key, opts)
  self.opts == opts
end
add(key) click to toggle source
# File lib/msgr/route.rb, line 35
def add(key)
  raise ArgumentError.new 'Routing key required.' unless key.present?

  keys << key
end
keys() click to toggle source
# File lib/msgr/route.rb, line 26
def keys
  @keys ||= []
end
Also aliased as: routing_keys
name() click to toggle source
# File lib/msgr/route.rb, line 45
def name
  "msgr.consumer.#{consumer}.#{action}"
end
prefetch() click to toggle source
# File lib/msgr/route.rb, line 31
def prefetch
  @opts[:prefetch] || 1
end
routing_keys()
Alias for: keys