Sha256: 60cb0979c31c94d4f725a14c18685895edfed5c570819114bb354c7dbb4a85fa

Contents?: true

Size: 795 Bytes

Versions: 7

Compression:

Stored size: 795 Bytes

Contents

module Glimmer
  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))
        Glimmer.logger.debug "#{@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
        Glimmer.logger.debug "Command: #{command_symbol} cannot be handled!"
        return nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
glimmer-0.4.6 lib/glimmer/command_handler_chain_link.rb
glimmer-0.4.5 lib/glimmer/command_handler_chain_link.rb
glimmer-0.4.4 lib/glimmer/command_handler_chain_link.rb
glimmer-0.4.3 lib/glimmer/command_handler_chain_link.rb
glimmer-0.4.2 lib/glimmer/command_handler_chain_link.rb
glimmer-0.4.1 lib/glimmer/command_handler_chain_link.rb
glimmer-0.4.0 lib/glimmer/command_handler_chain_link.rb