Sha256: 4d4c4474ed4fa4fdf5253ced50dba4168051e026c830fda223793a55bc8f1882

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

# Copyright (c) 2008 Simon Menke
# 
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class Message::Recorder::Collector < ::Array # :nodoc:
  
  def initialize(array=[], root=nil)
    super(array)
    push ::Message::Recorder::Chain.new if self.empty?
    root_collector = root
  end
  
  def collect_messages
    ::Message::Recorder::ChainingMock.new(self)
  end
  
  def record(m, *args, &block)
    each { |chain| chain.record(m, *args, &block) }
  end
  
  def branch
    self.deep_copy
  end
  
  def deep_copy
    ::Message::Recorder::Collector.new(collect { |chain| chain.dup })
  end
  
  def send_to(subject, recorder)
    results = ::Array.new
    each { |chain| results << chain.send_to(subject, recorder) }
    results
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
message-recorder-1.0.0 lib/message-recorder/collector.rb
message-recorder-1.0.1 lib/message-recorder/collector.rb
message-recorder-1.0.2 lib/message-recorder/collector.rb
message-recorder-1.0.3 lib/message-recorder/collector.rb