Sha256: 4d4a51361556d76b3aece84e6b6a39f755c9166d8ee66dc86e4bce4883b4694b
Contents?: true
Size: 921 Bytes
Versions: 8
Compression:
Stored size: 921 Bytes
Contents
require "gm/notepad/input_handlers/default_handler" module Gm module Notepad # Responsible for registering the various input handlers class InputHandlerRegistry def initialize @registry = [] yield(self) if block_given? end def handler_for(input:, skip_default: false, table_registry: Container.resolve(:table_registry)) handler = nil @registry.each do |handler_builder| if handler = handler_builder.build_if_handled(input: input, table_registry: table_registry) break end end return handler if handler return nil if skip_default default_handler_builder.build_if_handled(input: input, table_registry: table_registry) end def register(handler:) @registry << handler end def default_handler_builder InputHandlers::DefaultHandler end end end end
Version data entries
8 entries across 8 versions & 1 rubygems