Sha256: 7a25e3746d1f53bb7270d580cdbebb6f496ae461edbf9300c7c0cef0cef60d7a
Contents?: true
Size: 742 Bytes
Versions: 3
Compression:
Stored size: 742 Bytes
Contents
require 'dry-equalizer' module Messaging module Routing # Internal: Used by routing to match a pattern against a callable (handler) class Route include Dry::Equalizer(:matcher, :handler) attr_reader :matcher attr_reader :handler def initialize(pattern, handler) @matcher = MessageMatcher.new(pattern: pattern) @handler = handler verify_handler! end def call(message) return unless @matcher.matches?(message) @handler.call(message) end def topics matcher.topics end private def verify_handler! raise ArgumentError, 'Handler must be callable' unless handler.respond_to? :call end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
messaging-3.5.1 | lib/messaging/routing/route.rb |
messaging-3.4.3 | lib/messaging/routing/route.rb |
messaging-3.4.2 | lib/messaging/routing/route.rb |