Class: Sentinel::Configuration
- Inherits:
-
Object
- Object
- Sentinel::Configuration
- Defined in:
- lib/sentinel/configuration.rb
Constant Summary collapse
- DEFAULT_URI =
(ENV['sentinel_uri'] || 'http://localhost:3000/reports').freeze
- DEFAULT_LEVEL =
(ENV['sentinel_level'] || 'INFO').freeze
- DEFAULT_METHOD =
(ENV['sentinel_method'] || 'post').freeze
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#method ⇒ Object
Returns the value of attribute method.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #default_logger ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(options) ⇒ Object
- #merge!(options) ⇒ Object
- #use_ssl? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 |
# File 'lib/sentinel/configuration.rb', line 12 def initialize(uri:, level:, method:) @uri = uri @level = level @method = method end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/sentinel/configuration.rb', line 5 def level @level end |
#method ⇒ Object
Returns the value of attribute method.
6 7 8 |
# File 'lib/sentinel/configuration.rb', line 6 def method @method end |
#uri ⇒ Object
Returns the value of attribute uri.
4 5 6 |
# File 'lib/sentinel/configuration.rb', line 4 def uri @uri end |
Instance Method Details
#default_logger ⇒ Object
42 43 44 |
# File 'lib/sentinel/configuration.rb', line 42 def default_logger @default_logger ||= defined?(::Rails) ? ::Rails.logger : ::Logger.new(STDERR) end |
#merge(options) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/sentinel/configuration.rb', line 24 def merge() new_configuration = clone new_configuration.merge!() new_configuration end |
#merge!(options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sentinel/configuration.rb', line 31 def merge!() .each do |name, value| variable_name = "@#{name}" next unless instance_variable_defined?(variable_name) instance_variable_set(variable_name, value) end self end |
#use_ssl? ⇒ Boolean
46 47 48 |
# File 'lib/sentinel/configuration.rb', line 46 def use_ssl? uri.match(/^https:/) ? true : false end |