Sha256: ee27a980925fa602c7303ca79ded1897eab6cbeedc9f16903e7f45f2622915c3

Contents?: true

Size: 706 Bytes

Versions: 4

Compression:

Stored size: 706 Bytes

Contents

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

4 entries across 4 versions & 1 rubygems

Version Path
glimmer-0.1.4.470 lib/command_handler_chain_link.rb
glimmer-0.1.4.swt.pre.4.7.0 lib/command_handler_chain_link.rb
glimmer-0.1.3 lib/command_handler_chain_link.rb
glimmer-0.1.2 lib/command_handler_chain_link.rb