Class: MailToHipChat::ChuteChain

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeChuteChain



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(message)
  @chutes.any? { |chute| chute.call(message) }
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