Class: Adhearsion::Configuration
- Extended by:
- ConfigurationEntryPoint
- Defined in:
- lib/adhearsion/initializer/configuration.rb
Defined Under Namespace
Modules: ConfigurationEntryPoint Classes: AbstractConfiguration, AsteriskConfiguration, DatabaseConfiguration, DrbConfiguration, FreeswitchConfiguration, LdapConfiguration, RailsConfiguration, TelephonyPlatformConfiguration, XMPPConfiguration
Instance Attribute Summary collapse
-
#automatically_answer_incoming_calls ⇒ Object
Returns the value of attribute automatically_answer_incoming_calls.
-
#components_to_load ⇒ Object
Returns the value of attribute components_to_load.
-
#end_call_on_error ⇒ Object
Returns the value of attribute end_call_on_error.
-
#end_call_on_hangup ⇒ Object
Returns the value of attribute end_call_on_hangup.
Class Method Summary collapse
Instance Method Summary collapse
- #add_component(*list) ⇒ Object
- #ahnrc ⇒ Object
-
#ahnrc=(new_ahnrc) ⇒ Object
Load the contents of an .ahnrc file into this Configuration.
-
#files_from_setting(*path_through_config) ⇒ Object
Adhearsion’s .ahnrc file is used to define paths to certain parts of the framework.
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #logging(options) ⇒ Object
Methods included from ConfigurationEntryPoint
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
40 41 42 43 44 45 46 |
# File 'lib/adhearsion/initializer/configuration.rb', line 40 def initialize @automatically_answer_incoming_calls = true @end_call_on_hangup = true @end_call_on_error = true @components_to_load = [] yield self if block_given? end |
Instance Attribute Details
#automatically_answer_incoming_calls ⇒ Object
Returns the value of attribute automatically_answer_incoming_calls.
35 36 37 |
# File 'lib/adhearsion/initializer/configuration.rb', line 35 def automatically_answer_incoming_calls @automatically_answer_incoming_calls end |
#components_to_load ⇒ Object
Returns the value of attribute components_to_load.
38 39 40 |
# File 'lib/adhearsion/initializer/configuration.rb', line 38 def components_to_load @components_to_load end |
#end_call_on_error ⇒ Object
Returns the value of attribute end_call_on_error.
37 38 39 |
# File 'lib/adhearsion/initializer/configuration.rb', line 37 def end_call_on_error @end_call_on_error end |
#end_call_on_hangup ⇒ Object
Returns the value of attribute end_call_on_hangup.
36 37 38 |
# File 'lib/adhearsion/initializer/configuration.rb', line 36 def end_call_on_hangup @end_call_on_hangup end |
Class Method Details
.configure(&block) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/adhearsion/initializer/configuration.rb', line 26 def configure(&block) if Adhearsion.const_defined?(:AHN_CONFIG) yield AHN_CONFIG if block_given? else Adhearsion.const_set(:AHN_CONFIG, new(&block)) end end |
Instance Method Details
#add_component(*list) ⇒ Object
72 73 74 |
# File 'lib/adhearsion/initializer/configuration.rb', line 72 def add_component(*list) AHN_CONFIG.components_to_load |= list end |
#ahnrc ⇒ Object
48 49 50 |
# File 'lib/adhearsion/initializer/configuration.rb', line 48 def ahnrc @ahnrc end |
#ahnrc=(new_ahnrc) ⇒ Object
Load the contents of an .ahnrc file into this Configuration.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/adhearsion/initializer/configuration.rb', line 57 def ahnrc=(new_ahnrc) case new_ahnrc when Hash @raw_ahnrc = new_ahnrc.to_yaml.freeze @ahnrc = new_ahnrc.clone.freeze when String @raw_ahnrc = new_ahnrc.clone.freeze @ahnrc = YAML.load(new_ahnrc).freeze end end |
#files_from_setting(*path_through_config) ⇒ Object
Adhearsion’s .ahnrc file is used to define paths to certain parts of the framework. For example, the name dialplan.rb is actually specified in .ahnrc. This file can actually be just a filename, a filename with a glob (.e.g “*.rb”), an Array of filenames or even an Array of globs.
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/adhearsion/initializer/configuration.rb', line 85 def files_from_setting(*path_through_config) raise RuntimeError, "No ahnrc has been set yet!" unless @ahnrc queried_nested_setting = path_through_config.flatten.inject(@ahnrc) do |hash,key_name| if hash.kind_of?(Hash) && hash.has_key?(key_name) hash[key_name] else raise NameError, "Paths #{path_through_config.inspect} not found in .ahnrc!" end end raise NameError, "Paths #{path_through_config.inspect} not found in .ahnrc!" unless queried_nested_setting queried_nested_setting = Array queried_nested_setting queried_nested_setting.map { |filename| files_from_glob(filename) }.flatten.uniq end |
#logging(options) ⇒ Object
68 69 70 |
# File 'lib/adhearsion/initializer/configuration.rb', line 68 def logging() Adhearsion::Logging.logging_level = [:level] end |