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_optionsmerged on top. -
#correlation_id ⇒ #call?
Callable that produces a correlation id when invoked by Runtime at root-chain construction.
-
#default_executor ⇒ Symbol?
Default
:executorfor parallel workflow groups when a group omitsexecutor:; falls back to Configuration#default_executor. -
#initialize(options = EMPTY_HASH) ⇒ Settings
constructor
A new instance of Settings.
-
#log_exclusions ⇒ Array<Symbol>
Keys to exclude from
Runtimelog output. -
#log_formatter ⇒ #call
Logger formatter used when logging task results.
-
#log_level ⇒ Integer
Loggerseverity 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.
18 19 20 |
# File 'lib/cmdx/settings.rb', line 18 def initialize( = EMPTY_HASH) @options = .freeze end |
Instance Method Details
#backtrace_cleaner ⇒ #call?
Returns callable that cleans fault backtrace frames.
65 66 67 68 69 |
# File 'lib/cmdx/settings.rb', line 65 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).
27 28 29 30 31 |
# File 'lib/cmdx/settings.rb', line 27 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.
88 89 90 91 92 |
# File 'lib/cmdx/settings.rb', line 88 def correlation_id @options.fetch(:correlation_id) do CMDx.configuration.correlation_id end end |
#default_executor ⇒ Symbol?
Returns default :executor for parallel workflow groups when
a group omits executor:; falls back to Configuration#default_executor.
96 97 98 99 100 |
# File 'lib/cmdx/settings.rb', line 96 def default_executor @options.fetch(:default_executor) do CMDx.configuration.default_executor 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).
58 59 60 61 62 |
# File 'lib/cmdx/settings.rb', line 58 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.
41 42 43 44 45 |
# File 'lib/cmdx/settings.rb', line 41 def log_formatter @options.fetch(:log_formatter) do CMDx.configuration.log_formatter end end |
#log_level ⇒ Integer
Returns Logger severity level.
48 49 50 51 52 |
# File 'lib/cmdx/settings.rb', line 48 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.
34 35 36 37 38 |
# File 'lib/cmdx/settings.rb', line 34 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.
79 80 81 82 83 |
# File 'lib/cmdx/settings.rb', line 79 def strict_context @options.fetch(:strict_context) do CMDx.configuration.strict_context end end |
#tags ⇒ Array<Symbol, String>
Returns task tags.
72 73 74 |
# File 'lib/cmdx/settings.rb', line 72 def @options[:tags] || EMPTY_ARRAY end |