Class: Adhearsion::VoIP::DSL::DialingDSL::RouteRule

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

Defined Under Namespace

Classes: RouteException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ RouteRule

Returns a new instance of RouteRule.



106
107
108
109
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 106

def initialize(hash={})
  @patterns  = Array hash[:patterns]
  @providers = Array hash[:providers]
end

Instance Attribute Details

#patternsObject (readonly)

Returns the value of attribute patterns.



104
105
106
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 104

def patterns
  @patterns
end

#providersObject (readonly)

Returns the value of attribute providers.



104
105
106
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 104

def providers
  @providers
end

Instance Method Details

#===(other) ⇒ Object



136
137
138
139
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 136

def ===(other)
  patterns.each { |pattern| return true if pattern === other }
  false
end

#>>(other) ⇒ Object



117
118
119
120
121
122
123
124
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 117

def >>(other)
  case other
    when RouteRule then merge! other
    when ProviderDefinition then providers << other
    else raise RouteException, "Unrecognized object in route definition: #{other.inspect}"
  end
  self
end

#merge!(other) ⇒ Object



111
112
113
114
115
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 111

def merge!(other)
  providers.concat other.providers
  patterns.concat  other.patterns
  self
end

#unshift_pattern(pattern) ⇒ Object



141
142
143
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 141

def unshift_pattern(pattern)
  patterns.unshift pattern
end

#|(other) ⇒ Object



126
127
128
129
130
131
132
133
134
# File 'lib/adhearsion/voip/dsl/dialing_dsl.rb', line 126

def |(other)
  case other
    when RouteRule then merge! other
    when Regexp
      patterns << other
      self
    else raise other.inspect
  end
end