Sha256: 7f1a2ec2ab5cd5a614e3236071ac20438269ca1d245e8dbaf380b0abf9d5c435

Contents?: true

Size: 687 Bytes

Versions: 12

Compression:

Stored size: 687 Bytes

Contents

module Resourcelogic
  class ResponseCollector
    
    attr_reader :responses
    
    delegate :clear, :to => :responses
    
    def initialize
      @responses = []
    end
    
    def method_missing(method_name, &block)
      @responses.delete self[method_name]
      value = [method_name, block || nil]
      if method_name == :html
        @responses.unshift(value)
      else
        @responses << value
      end
    end
    
    def [](symbol)
      @responses.find { |method, block| method == symbol }
    end
    
    def dup
      returning ResponseCollector.new do |duplicate|
        duplicate.instance_variable_set(:@responses, responses.dup)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
binarylogic-resourcelogic-0.12.1 lib/resourcelogic/response_collector.rb
binarylogic-resourcelogic-0.12.2 lib/resourcelogic/response_collector.rb
binarylogic-resourcelogic-0.12.3 lib/resourcelogic/response_collector.rb
binarylogic-resourcelogic-0.12.4 lib/resourcelogic/response_collector.rb
binarylogic-resourcelogic-0.12.5 lib/resourcelogic/response_collector.rb
binarylogic-resourcelogic-0.12.6 lib/resourcelogic/response_collector.rb
resourcelogic-0.12.6 lib/resourcelogic/response_collector.rb
resourcelogic-0.12.5 lib/resourcelogic/response_collector.rb
resourcelogic-0.12.3 lib/resourcelogic/response_collector.rb
resourcelogic-0.12.4 lib/resourcelogic/response_collector.rb
resourcelogic-0.12.1 lib/resourcelogic/response_collector.rb
resourcelogic-0.12.2 lib/resourcelogic/response_collector.rb