module Redispatcher::Dispatchable::ClassMethods

Public Instance Methods

dispatcher_class() click to toggle source

Infers the dispatcher class ‘Topic` maps to `TopicRedispatcher`). @return [Class] the inferred dispatcher class.

# File lib/redispatcher/dispatchable.rb, line 38
def dispatcher_class
  prefix = respond_to?(:model_name) ? model_name : name
  dispatcher_name = "#{prefix}Dispatcher"
  dispatcher_name.constantize
rescue NameError => error
  if superclass.respond_to?(:dispatcher_class)
    superclass.dispatcher_class
  else
    raise unless error.missing_name?(dispatcher_name)
    raise Redispatcher::UninferrableDispatcherError.new(self)
  end
end
dispatcher_class?() click to toggle source
# File lib/redispatcher/dispatchable.rb, line 30
def dispatcher_class?
  dispatcher_class
rescue Redispatcher::UninferrableDispatcherError
  false
end