Class: RequestHeadersLogger::Configuration
- Inherits:
-
Object
- Object
- RequestHeadersLogger::Configuration
- Defined in:
- lib/request_headers_logger/configuration.rb
Defined Under Namespace
Classes: InvalidKey
Constant Summary collapse
- CONFIG_KEYS =
[ :log_format, # [logger_format] default or json :tag_format, # [tag_format] ].freeze
- LOG_FORMATS =
%w[text json].freeze
- TAG_FORMATS =
%w[val key_val].freeze
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #log_format ⇒ Object
- #tag_format ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 |
# File 'lib/request_headers_logger/configuration.rb', line 19 def initialize @configs = { log_format: LOG_FORMATS.first, tag_format: TAG_FORMATS.first } end |
Instance Method Details
#[](key) ⇒ Object
32 33 34 |
# File 'lib/request_headers_logger/configuration.rb', line 32 def [](key) @configs[key] end |
#[]=(key, value) ⇒ Object
26 27 28 29 30 |
# File 'lib/request_headers_logger/configuration.rb', line 26 def []=(key, value) raise InvalidKey, key unless CONFIG_KEYS.include?(key) @configs[key] = value end |
#log_format ⇒ Object
36 37 38 |
# File 'lib/request_headers_logger/configuration.rb', line 36 def log_format LOG_FORMATS.include?(@configs[:log_format]) ? @configs[:log_format] : LOG_FORMATS.first end |
#tag_format ⇒ Object
40 41 42 |
# File 'lib/request_headers_logger/configuration.rb', line 40 def tag_format TAG_FORMATS.include?(@configs[:tag_format]) ? @configs[:tag_format] : TAG_FORMATS.first end |