Class: Mailman::Route
- Inherits:
-
Object
- Object
- Mailman::Route
- 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)
-
- (Proc) block
readonly
The block that should be run if the conditions match.
-
- (Array) conditions
readonly
The list of condition instances associated with the route.
-
- (Class, String) klass
readonly
The class (and optional instance method) to run instead of a block.
Instance Method Summary (collapse)
-
- (Route) initialize
constructor
A new instance of Route.
-
- (Hash) match!(message)
Checks whether a message matches the route.
Constructor Details
- (Route) initialize
A new instance of Route
17 18 19 |
# File 'lib/mailman/route.rb', line 17 def initialize @conditions = [] end |
Instance Attribute Details
- (Proc) block (readonly)
The block that should be run if the conditions match
8 9 10 |
# File 'lib/mailman/route.rb', line 8 def block @block end |
- (Array) conditions (readonly)
The list of condition instances associated with the route
15 16 17 |
# File 'lib/mailman/route.rb', line 15 def conditions @conditions end |
- (Class, String) klass (readonly)
The class (and optional instance method) to run instead of a block
12 13 14 |
# File 'lib/mailman/route.rb', line 12 def klass @klass end |
Instance Method Details
- (Hash) match!(message)
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!() params = {} args = [] @conditions.each do |condition| if result = condition.match() params.merge!(result[0]) args += result[1] else return nil end end { :block => @block, :klass => @klass, :params => params, :args => args } end |