Class: Adhearsion::Configuration
- Extended by:
- ConfigurationEntryPoint
- Defined in:
- lib/adhearsion/initializer/configuration.rb
Defined Under Namespace
Modules: ConfigurationEntryPoint Classes: AbstractConfiguration, AsteriskConfiguration, DatabaseConfiguration, DrbConfiguration, FreeswitchConfiguration, RailsConfiguration, TelephonyPlatformConfiguration
Instance Attribute Summary collapse
-
#automatically_answer_incoming_calls ⇒ Object
Returns the value of attribute automatically_answer_incoming_calls.
-
#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
- #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.
39 40 41 42 43 44 |
# File 'lib/adhearsion/initializer/configuration.rb', line 39 def initialize @automatically_answer_incoming_calls = true @end_call_on_hangup = true @end_call_on_error = true 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 |
#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
#ahnrc ⇒ Object
46 47 48 |
# File 'lib/adhearsion/initializer/configuration.rb', line 46 def ahnrc @ahnrc end |
#ahnrc=(new_ahnrc) ⇒ Object
Load the contents of an .ahnrc file into this Configuration.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/adhearsion/initializer/configuration.rb', line 55 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.
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/adhearsion/initializer/configuration.rb', line 79 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
66 67 68 |
# File 'lib/adhearsion/initializer/configuration.rb', line 66 def logging() Adhearsion::Logging.logging_level = [:level] end |