class Rounders::Handlers::Handler

Attributes

matches[R]
rounder[R]

Public Class Methods

dispatch(rounder, mails) click to toggle source
# File lib/rounders/handlers/handler.rb, line 23
def dispatch(rounder, mails)
  mails.map do |mail|
    dispatchers.each do |dispatcher|
      matches = dispatcher.matcher.match(mail)
      next if matches.nil?
      new(rounder, matches).public_send(dispatcher.method_name, mail)
    end
  end
end
inherited(klass) click to toggle source
Calls superclass method
# File lib/rounders/handlers/handler.rb, line 18
def inherited(klass)
  super
  Rounders.handlers << klass
end
new(rounder, matches) click to toggle source
# File lib/rounders/handlers/handler.rb, line 45
def initialize(rounder, matches)
  @rounder = rounder
  @matches = matches
end
on(option, method_name) click to toggle source
# File lib/rounders/handlers/handler.rb, line 33
def on(option, method_name)
  matcher = Rounders::Matchers::Matcher.build(option)
  dispatchers << Dispatcher.new(method_name, matcher)
end

Private Class Methods

dispatchers() click to toggle source
# File lib/rounders/handlers/handler.rb, line 40
def dispatchers
  @dispatchers ||= []
end