Class: CMDx::Settings
- Inherits:
-
Object
- Object
- CMDx::Settings
- Defined in:
- lib/cmdx/settings.rb
Overview
Per-task configuration overrides. Options are frozen on construction; #build returns a new instance rather than mutating. Every getter falls back to #configuration when the option wasn’t set on the task.
Instance Method Summary collapse
-
#backtrace_cleaner ⇒ #call?
Callable that cleans fault backtrace frames.
-
#build(new_options) ⇒ Settings
Returns a new Settings with ‘new_options` merged on top.
-
#correlation_id ⇒ String?
Correlation id or the global configuration’s correlation id.
-
#initialize(options = EMPTY_HASH) ⇒ Settings
constructor
A new instance of Settings.
-
#log_exclusions ⇒ Array<Symbol>
Keys to exclude from logging.
-
#log_formatter ⇒ #call
Logger formatter used when logging task results.
-
#log_level ⇒ Integer
‘Logger` severity level.
-
#logger ⇒ Logger
Task-level logger or the global configuration’s logger.
-
#strict_context ⇒ Boolean
Whether this task’s Context should raise on unknown dynamic reads; falls back to Configuration#strict_context.
-
#tags ⇒ Array<Symbol, String>
Returns a fresh array each call so callers can mutate the result without affecting other tasks (or hitting ‘FrozenError` on the shared sentinel).
Constructor Details
#initialize(options = EMPTY_HASH) ⇒ Settings
Returns a new instance of Settings.
17 18 19 |
# File 'lib/cmdx/settings.rb', line 17 def initialize( = EMPTY_HASH) @options = .freeze end |
Instance Method Details
#backtrace_cleaner ⇒ #call?
Returns callable that cleans fault backtrace frames.
61 62 63 64 65 |
# File 'lib/cmdx/settings.rb', line 61 def backtrace_cleaner @options.fetch(:backtrace_cleaner) do CMDx.configuration.backtrace_cleaner end end |
#build(new_options) ⇒ Settings
Returns a new Settings with ‘new_options` merged on top. Returns `self` unchanged when `new_options` is empty (used by Task inheritance).
26 27 28 29 30 |
# File 'lib/cmdx/settings.rb', line 26 def build() return self if .empty? self.class.new(@options.merge()) end |
#correlation_id ⇒ String?
Returns correlation id or the global configuration’s correlation id.
87 88 89 90 91 |
# File 'lib/cmdx/settings.rb', line 87 def correlation_id @options.fetch(:correlation_id) do CMDx.configuration.correlation_id end end |
#log_exclusions ⇒ Array<Symbol>
Returns keys to exclude from logging.
54 55 56 57 58 |
# File 'lib/cmdx/settings.rb', line 54 def log_exclusions @options.fetch(:log_exclusions) do CMDx.configuration.log_exclusions end end |
#log_formatter ⇒ #call
Returns Logger formatter used when logging task results.
40 41 42 43 44 |
# File 'lib/cmdx/settings.rb', line 40 def log_formatter @options.fetch(:log_formatter) do CMDx.configuration.log_formatter end end |
#log_level ⇒ Integer
Returns ‘Logger` severity level.
47 48 49 50 51 |
# File 'lib/cmdx/settings.rb', line 47 def log_level @options.fetch(:log_level) do CMDx.configuration.log_level end end |
#logger ⇒ Logger
Returns task-level logger or the global configuration’s logger.
33 34 35 36 37 |
# File 'lib/cmdx/settings.rb', line 33 def logger @options.fetch(:logger) do CMDx.configuration.logger end end |
#strict_context ⇒ Boolean
Returns whether this task’s Context should raise on unknown dynamic reads; falls back to Configuration#strict_context.
80 81 82 83 84 |
# File 'lib/cmdx/settings.rb', line 80 def strict_context @options.fetch(:strict_context) do CMDx.configuration.strict_context end end |
#tags ⇒ Array<Symbol, String>
Returns a fresh array each call so callers can mutate the result without affecting other tasks (or hitting ‘FrozenError` on the shared sentinel).
72 73 74 75 |
# File 'lib/cmdx/settings.rb', line 72 def = @options[:tags] ? .dup : [] end |