Class: MailToHipChat::ChuteChain
- Inherits:
-
Object
- Object
- MailToHipChat::ChuteChain
- Defined in:
- lib/mail_to_hip_chat/chute_chain.rb
Overview
A ChuteChain is used to hold a collection of chutes and to check whether any of those chutes is able to handle a message to hand off to HipChat. Anything that responds to #call can be pushed onto the chain.
Instance Method Summary collapse
-
#accept(message) ⇒ true, false
Takes in a message and traverses the chain looking for a chute that will handle it.
-
#initialize ⇒ ChuteChain
constructor
A new instance of ChuteChain.
-
#push(chute) ⇒ self
Pushes a chute onto the chain.
Constructor Details
#initialize ⇒ ChuteChain
Returns a new instance of ChuteChain.
7 8 9 |
# File 'lib/mail_to_hip_chat/chute_chain.rb', line 7 def initialize @chutes = [] end |
Instance Method Details
#accept(message) ⇒ true, false
Takes in a message and traverses the chain looking for a chute that will handle it.
27 28 29 |
# File 'lib/mail_to_hip_chat/chute_chain.rb', line 27 def accept() @chutes.any? { |chute| chute.call() } end |
#push(chute) ⇒ self
Pushes a chute onto the chain.
16 17 18 19 |
# File 'lib/mail_to_hip_chat/chute_chain.rb', line 16 def push(chute) @chutes.push(chute) self end |