Module: SmswayApi::Configuration
- Included in:
- SmswayApi
- Defined in:
- lib/smsway_api/configuration.rb
Overview
Note:
‘SmswayApi::Configuration` extends `Smsway` so these methods should be called from the latter.
General configuration module.
Constant Summary collapse
- OPTION_NAMES =
Available options.
[ :login, :password, :default_sender, :logger, :log_requests, :log_errors, :log_responses ]
- DEFAULT_MAX_RETRIES =
Default max retries count.
2
- DEFAULT_LOGGER_OPTIONS =
Logger default options.
{ requests: true, errors: true, responses: false }
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
A global configuration set via the block.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
56 57 58 |
# File 'lib/smsway_api/configuration.rb', line 56 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
A global configuration set via the block.
41 42 43 44 |
# File 'lib/smsway_api/configuration.rb', line 41 def configure yield self if block_given? self end |
#reset ⇒ Object
Reset all configuration options to defaults.
47 48 49 50 51 52 53 |
# File 'lib/smsway_api/configuration.rb', line 47 def reset @max_retries = DEFAULT_MAX_RETRIES @logger = ::Logger.new(STDOUT) @log_requests = DEFAULT_LOGGER_OPTIONS[:requests] @log_errors = DEFAULT_LOGGER_OPTIONS[:errors] @log_responses = DEFAULT_LOGGER_OPTIONS[:responses] end |