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

#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
# File 'lib/ar/rule_manager.rb', line 20

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

#add_rule(*args, &block) ⇒ Object



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

def add_rule(*args, &block)
  @last_rule = target = args.first
  case target
  when Hash
    @last_rule = target.keys.first
    rules.merge! target
  when String
    rules[target] = args[1]
  when Regexp
    if block_given?
      rules[target] = block
    else
      rules[target] = args[1]
    end
  end
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