Class: Mailman::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/mailman/route.rb,
lib/mailman/route/matcher.rb,
lib/mailman/route/condition.rb,
lib/mailman/route/conditions.rb,
lib/mailman/route/regexp_matcher.rb,
lib/mailman/route/string_matcher.rb

Overview

The main route class. Has condition methods defined on it by Condition.inherited. Stores a route with a set of conditions and matches against them.

Defined Under Namespace

Classes: BodyCondition, CcCondition, Condition, FromCondition, Matcher, RegexpMatcher, StringMatcher, SubjectCondition, ToCondition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRoute


17
18
19
# File 'lib/mailman/route.rb', line 17

def initialize
  @conditions = []
end

Instance Attribute Details

#blockProc (readonly)


8
9
10
# File 'lib/mailman/route.rb', line 8

def block
  @block
end

#conditionsArray (readonly)


15
16
17
# File 'lib/mailman/route.rb', line 15

def conditions
  @conditions
end

#klassClass, String (readonly)


12
13
14
# File 'lib/mailman/route.rb', line 12

def klass
  @klass
end

Instance Method Details

#match!(message) ⇒ Hash

Checks whether a message matches the route.


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mailman/route.rb', line 25

def match!(message)
  params = {}
  args = []
  @conditions.each do |condition|
    if result = condition.match(message)
      params.merge!(result[0])
      args += result[1]
    else
      return nil
    end
  end
  { :block => @block, :klass => @klass, :params => params, :args => args }
end