Sha256: 2871ad0056376ab1b91cddae5776727255ce39475f8e5f3609f13dd401b1161d

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

require 'pymn/chain_of_responsibility'

class ErrorLogger
  include Pymn::ChainOfResponsibility

  def initialize(buffer)
    @buffer = buffer
  end

  def log(type, message)
    @buffer << "ERROR: #{message.upcase}"
  end

  responsibility(:log) { |type, message| type == :error }
end

class WarnLogger
  include Pymn::ChainOfResponsibility

  def initialize(buffer)
    @buffer = buffer
  end

  def log(type, message)
    @buffer << "Warning: #{message}"
  end

  responsibility(:log) { |type, message| type == :warn }
end

class InfoLogger
  include Pymn::ChainOfResponsibility

  def initialize(buffer)
    @buffer = buffer
  end

  def log(type, message)
    @buffer << "Info: #{message}"
  end

  responsibility(:log) { |type, message| type == :info }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pymn-0.0.2 integration/fixtures/chain_of_responsibility.rb
pymn-0.0.1 integration/fixtures/chain_of_responsibility.rb