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 ⇒ #call?
Callable that produces a correlation id when invoked by Runtime at root-chain construction.
-
#initialize(options = EMPTY_HASH) ⇒ Settings
constructor
A new instance of Settings.
-
#log_exclusions ⇒ Array<Symbol>
Keys to exclude from ‘Runtime` log output.
-
#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>
Task tags.
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.
64 65 66 67 68 |
# File 'lib/cmdx/settings.rb', line 64 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 ⇒ #call?
Returns callable that produces a correlation id when invoked by Runtime at root-chain construction. Resolution order: task-level setting → Configuration#correlation_id → nil.
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 ‘Runtime` log output. Matched against Result#to_h keys. Common values for redaction: `:context` (may contain secrets / PII), `:cause` (raw exception), `:reason` (may embed exception messages from unhandled errors).
57 58 59 60 61 |
# File 'lib/cmdx/settings.rb', line 57 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.
78 79 80 81 82 |
# File 'lib/cmdx/settings.rb', line 78 def strict_context @options.fetch(:strict_context) do CMDx.configuration.strict_context end end |
#tags ⇒ Array<Symbol, String>
Returns task tags.
71 72 73 |
# File 'lib/cmdx/settings.rb', line 71 def @options[:tags] || EMPTY_ARRAY end |