Sha256: 04b6a985d451cf78579e6361effacbbc26507cc9d28c232f860b26ef07eaa6d8

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

# Copyright (C) 2007-2008 Annas Al Maleh
# Licensed under the LGPL. See /COPYING.LGPL for more details.

class CommandHandlerChainLink
  def initialize(command_handler)
    @command_handler = command_handler
  end
  def chain_to(next_chain_link)
    @next_chain_link = next_chain_link
  end
  def handle(parent, command_symbol, *args, &block)
    if (@command_handler.can_handle?(parent, command_symbol, *args, &block))
      puts "#{@command_handler.class.to_s} will handle command: #{command_symbol} with arguments #{args}"
      return @command_handler.do_handle(parent, command_symbol, *args, &block)
    elsif @next_chain_link
      return @next_chain_link.handle(parent, command_symbol, *args, &block)
    else
      puts "Command: #{command_symbol} cannot be handled!"
      return nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glimmer-0.1.0.0 src/command_handler_chain_link.rb