Module: RepsClient::Configuration
Instance Attribute Summary collapse
-
#logger ⇒ Logger
The logger to use for debug messages (defaults to STDOUT).
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ RepsClient
Configures this module through the given
block
. -
#debug? ⇒ true, false
True if debug logging is enabled; false otherwie.
-
#options ⇒ Hash<Symbol,Object>
Create a hash of configuration options and their values.
-
#reset ⇒ Object
Resets this module’s configuration.
Instance Attribute Details
#logger ⇒ Logger
Returns the logger to use for debug messages (defaults to STDOUT).
54 55 56 |
# File 'lib/reps_client/configuration.rb', line 54 def logger @logger ||= Logger.new(STDOUT) end |
Class Method Details
.extended(base) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/reps_client/configuration.rb', line 18 def self.extended(base) # Default configuration - happens whether or not .configure is called base.config :reps_client do default :endpoint => DEFAULT_ENDPOINT default :namespace => DEFAULT_NAMESPACE default :debug => 'false' end end |
Instance Method Details
#configure {|_self| ... } ⇒ RepsClient
Configures this module through the given block
. Default configuration options will be applied unless they are explicitly overridden in the block
.
82 83 84 85 86 87 88 |
# File 'lib/reps_client/configuration.rb', line 82 def configure config :reps_client do yield self end self end |
#debug? ⇒ true, false
Returns true if debug logging is enabled; false otherwie.
46 47 48 |
# File 'lib/reps_client/configuration.rb', line 46 def debug? self[:debug] == 'true' end |
#options ⇒ Hash<Symbol,Object>
Create a hash of configuration options and their values.
94 95 96 97 98 |
# File 'lib/reps_client/configuration.rb', line 94 def VALID_CONFIG_OPTIONS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Resets this module’s configuration. Configuration options will be set to default values if they exist; otherwise, they will be set to nil.
107 108 109 |
# File 'lib/reps_client/configuration.rb', line 107 def reset VALID_CONFIG_OPTIONS.each { |opt| self.send("#{opt}=", nil) } end |