Module: Sequent::Core::Helpers::MessageHandler::ClassMethods

Defined in:
lib/sequent/core/helpers/message_handler.rb

Instance Method Summary collapse

Instance Method Details

#handles_message?(message) ⇒ Boolean

Returns:



65
66
67
# File 'lib/sequent/core/helpers/message_handler.rb', line 65

def handles_message?(message)
  message_router.matches_message?(message)
end

#message_mappingObject



61
62
63
# File 'lib/sequent/core/helpers/message_handler.rb', line 61

def message_mapping
  message_router.instanceof_routes
end

#message_routerObject



69
70
71
# File 'lib/sequent/core/helpers/message_handler.rb', line 69

def message_router
  @message_router ||= MessageRouter.new
end

#on(*args, **opts, &block) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sequent/core/helpers/message_handler.rb', line 42

def on(*args, **opts, &block)
  OnArgumentsValidator.validate_arguments!(*args)

  message_matchers = args.map { |arg| MessageMatchers::ArgumentCoercer.coerce_argument(arg) }

  message_router.register_matchers(
    *message_matchers,
    block,
  )

  opts.each do |name, value|
    option_registry.call_option(self, name, message_matchers, value)
  end
end

#option(name, &block) ⇒ Object



57
58
59
# File 'lib/sequent/core/helpers/message_handler.rb', line 57

def option(name, &block)
  option_registry.register_option(name, block)
end