Class: Freeswitch::ESL::Configuration
- Inherits:
-
Object
- Object
- Freeswitch::ESL::Configuration
- Extended by:
- Forwardable
- Defined in:
- lib/freeswitch/esl/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #update(**options) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
39 40 41 |
# File 'lib/freeswitch/esl/configuration.rb', line 39 def initialize(**) @config = self.class.build(**) end |
Class Method Details
.build(**options) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/freeswitch/esl/configuration.rb', line 27 def build(**) config = Configatron::RootStore.new config.freeswitch.configure_from_hash(defaults[:freeswitch].dup.merge([:freeswitch] || {})) config.logger = [:logger] || defaults[:logger] config.debug = [:debug] || defaults[:debug] config end |
.defaults ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/freeswitch/esl/configuration.rb', line 12 def defaults @defaults ||= { freeswitch: { host: ENV.fetch("FREESWITCH_ESL_HOST", "127.0.0.1"), port: ENV.fetch("FREESWITCH_ESL_PORT", 8021).to_i, password: ENV.fetch("FREESWITCH_ESL_PASSWORD", nil), reconnect: %w[true 1 yes].include?(ENV.fetch("FREESWITCH_ESL_RECONNECT", "true").downcase), retry_delay: ENV.fetch("FREESWITCH_ESL_RETRY_DELAY", 1.0).to_f, max_retries: Float::INFINITY }, logger: Freeswitch::ESL::Logger.default_logger, debug: false }.freeze end |
Instance Method Details
#update(**options) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/freeswitch/esl/configuration.rb', line 43 def update(**) %i[freeswitch logger debug].each do |key| next unless .key?(key) if key == :freeswitch @config.freeswitch.configure_from_hash([:freeswitch]) else @config[key] = [key] || @config[key] end end end |