Class: Vissen::Input::Subscription
- Inherits:
-
Object
- Object
- Vissen::Input::Subscription
- Extended by:
- Forwardable
- Defined in:
- lib/vissen/input/subscription.rb
Overview
Whenever a callable object wants to receive messages from a broker it is wrapped inside of a subscription. A subscription is a basic immutable value object with a minimal api that keeps track of three things: a Matcher, a callable handler and a numeric priority.
Instance Attribute Summary collapse
-
#priority ⇒ Integer
readonly
The subscription priority.
Instance Method Summary collapse
-
#handle(message) ⇒ Object
Calls the registered handler with the given message.
-
#initialize(matcher, handler, priority) ⇒ Subscription
constructor
A new instance of Subscription.
-
#match?(message) ⇒ true, false
This method is forwarded to
Matcher#match?
.
Constructor Details
#initialize(matcher, handler, priority) ⇒ Subscription
Returns a new instance of Subscription.
36 37 38 39 40 41 42 |
# File 'lib/vissen/input/subscription.rb', line 36 def initialize(matcher, handler, priority) @matcher = matcher @handler = handler @priority = priority freeze end |
Instance Attribute Details
#priority ⇒ Integer (readonly)
Returns the subscription priority.
15 16 17 |
# File 'lib/vissen/input/subscription.rb', line 15 def priority @priority end |
Instance Method Details
#handle(message) ⇒ Object
Calls the registered handler with the given message.
30 |
# File 'lib/vissen/input/subscription.rb', line 30 def_delegator :@handler, :call, :handle |
#match?(message) ⇒ true, false
This method is forwarded to Matcher#match?
.
22 |
# File 'lib/vissen/input/subscription.rb', line 22 def_delegator :@matcher, :match?, :match? |