Class: Bristow::Agencies::Workflow

Inherits:
Bristow::Agency show all
Defined in:
lib/bristow/agencies/workflow.rb

Instance Method Summary collapse

Methods inherited from Bristow::Agency

chat, #find_agent, #initialize

Methods included from Sgetter

included

Constructor Details

This class inherits a constructor from Bristow::Agency

Instance Method Details

#chat(messages, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/bristow/agencies/workflow.rb', line 4

def chat(messages, &block)
  return messages if agents.empty?

  agents.each.with_index(1) do |agent, index|
    last = index == agents.size
    messages = agent.chat(messages, &(last ? block : nil))
  end

  messages
end