Class: Adhearsion::VoIP::CallRouting::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/adhearsion/voip/call_routing.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRouter

Returns a new instance of Router.



50
51
52
# File 'lib/adhearsion/voip/call_routing.rb', line 50

def initialize
  @rules = []
end

Class Attribute Details

.rulesObject

Returns the value of attribute rules.



31
32
33
# File 'lib/adhearsion/voip/call_routing.rb', line 31

def rules
  @rules
end

Instance Attribute Details

#rulesObject (readonly)

Returns the value of attribute rules.



49
50
51
# File 'lib/adhearsion/voip/call_routing.rb', line 49

def rules
  @rules
end

Class Method Details

.calculate_route_for(end_point) ⇒ Object



40
41
42
43
44
# File 'lib/adhearsion/voip/call_routing.rb', line 40

def calculate_route_for(end_point)
  if rule = rules[end_point.to_s]
    rule.providers
  end
end

.define(&block) ⇒ Object



33
34
35
36
37
38
# File 'lib/adhearsion/voip/call_routing.rb', line 33

def define(&block)
  new.tap do |router|
    router.define(&block)
    rules.concat router.rules
  end
end

Instance Method Details

#define(&block) ⇒ Object



54
55
56
# File 'lib/adhearsion/voip/call_routing.rb', line 54

def define(&block)
  instance_eval(&block)
end

#route(*args, &block) ⇒ Object



58
59
60
# File 'lib/adhearsion/voip/call_routing.rb', line 58

def route(*args, &block)
  rules << Rule.new(*args, &block)
end