Class: AutoResp::RuleManager

Inherits:
Object
  • Object
show all
Includes:
RuleDSL
Defined in:
lib/ar/rule_manager.rb

Instance Method Summary collapse

Methods included from RuleDSL

#delay, #goto, #r, #url

Constructor Details

#initializeRuleManager

Returns a new instance of RuleManager.



9
10
# File 'lib/ar/rule_manager.rb', line 9

def initialize
end

Instance Method Details

#add_handler(handler) ⇒ Object



20
21
22
23
24
25
# File 'lib/ar/rule_manager.rb', line 20

def add_handler( handler )
  if @last_rule
    rules[@last_rule] ||= []
    rules[@last_rule] << handler
  end
end

#add_rule(*args, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ar/rule_manager.rb', line 27

def add_rule(*args, &block)
  @last_rule = target = args.first
  case target
  when Hash
    @last_rule = target.keys.first
    rules.merge! target
  when String, Regexp
    rules[target] = args[1]
  end
  rules[target] ||= block if block
end

#clearObject



16
17
18
# File 'lib/ar/rule_manager.rb', line 16

def clear
  @rules.clear
end

#rulesObject



12
13
14
# File 'lib/ar/rule_manager.rb', line 12

def rules
  @rules ||= {}
end