Class: Adhearsion::DialPlan::Loader
- Inherits:
-
Object
- Object
- Adhearsion::DialPlan::Loader
show all
- Defined in:
- lib/adhearsion/voip/dial_plan.rb
Defined Under Namespace
Classes: ContextNameCollector
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Loader
Returns a new instance of Loader.
193
194
195
|
# File 'lib/adhearsion/voip/dial_plan.rb', line 193
def initialize
@context_collector = ContextNameCollector.new
end
|
Class Attribute Details
.default_dial_plan_file_name ⇒ Object
Returns the value of attribute default_dial_plan_file_name.
159
160
161
|
# File 'lib/adhearsion/voip/dial_plan.rb', line 159
def default_dial_plan_file_name
@default_dial_plan_file_name
end
|
Class Method Details
.load(dial_plan_as_string) ⇒ Object
161
162
163
164
165
166
167
|
# File 'lib/adhearsion/voip/dial_plan.rb', line 161
def load(dial_plan_as_string)
string_io = StringIO.new dial_plan_as_string
def string_io.path
"(eval)"
end
load_dialplans string_io
end
|
.load_dialplans(*files) ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/adhearsion/voip/dial_plan.rb', line 169
def load_dialplans(*files)
files = Adhearsion::AHN_CONFIG.files_from_setting("paths", "dialplan") if files.empty?
files = Array files
files.map! do |file|
case file
when File, StringIO
file
when String
File.new file
else
raise ArgumentError, "Unrecognized type of file #{file.inspect}"
end
end
new.tap do |loader|
files.each do |file|
loader.load file
end
end
end
|
Instance Method Details
197
198
199
|
# File 'lib/adhearsion/voip/dial_plan.rb', line 197
def contexts
@context_collector.contexts
end
|
#load(dialplan_file) ⇒ Object
201
202
203
204
205
|
# File 'lib/adhearsion/voip/dial_plan.rb', line 201
def load(dialplan_file)
dialplan_code = dialplan_file.read
@context_collector.instance_eval(dialplan_code, dialplan_file.path)
nil
end
|