Class: CMDx::Configuration
- Inherits:
-
Object
- Object
- CMDx::Configuration
- Defined in:
- lib/cmdx/configuration.rb
Overview
Configuration class that manages global settings for CMDx including middlewares, callbacks, coercions, validators, breakpoints, backtraces, and logging.
Constant Summary collapse
- DEFAULT_BREAKPOINTS =
%w[failed].freeze
- DEFAULT_ROLLPOINTS =
%w[failed].freeze
Instance Attribute Summary collapse
-
#backtrace ⇒ Boolean
Returns whether to log backtraces for failed tasks.
-
#backtrace_cleaner ⇒ Proc?
Returns the proc used to clean backtraces before logging.
-
#callbacks ⇒ CallbackRegistry
Returns the callback registry for task lifecycle hooks.
-
#coercions ⇒ CoercionRegistry
Returns the coercion registry for type conversions.
-
#exception_handler ⇒ Proc?
Returns the proc called when exceptions occur during execution.
-
#logger ⇒ Logger
Returns the logger instance for CMDx operations.
-
#middlewares ⇒ MiddlewareRegistry
Returns the middleware registry for task execution.
-
#rollback_on ⇒ Array<String>
Returns the statuses that trigger a task execution rollback.
-
#task_breakpoints ⇒ Array<String>
Returns the breakpoint statuses for task execution interruption.
-
#validators ⇒ ValidatorRegistry
Returns the validator registry for attribute validation.
-
#workflow_breakpoints ⇒ Array<String>
Returns the breakpoint statuses for workflow execution interruption.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Initializes a new Configuration instance with default values.
-
#to_h ⇒ Hash{Symbol => Object}
Converts the configuration to a hash representation.
Constructor Details
#initialize ⇒ Configuration
Initializes a new Configuration instance with default values.
Creates new registry instances for middlewares, callbacks, coercions, and validators. Sets default breakpoints and configures a basic logger.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/cmdx/configuration.rb', line 139 def initialize @middlewares = MiddlewareRegistry.new @callbacks = CallbackRegistry.new @coercions = CoercionRegistry.new @validators = ValidatorRegistry.new @task_breakpoints = DEFAULT_BREAKPOINTS @workflow_breakpoints = DEFAULT_BREAKPOINTS @rollback_on = DEFAULT_ROLLPOINTS @backtrace = false @backtrace_cleaner = nil @exception_handler = nil @logger = Logger.new( $stdout, progname: "cmdx", formatter: LogFormatters::Line.new, level: Logger::INFO ) end |
Instance Attribute Details
#backtrace ⇒ Boolean
Returns whether to log backtraces for failed tasks.
94 95 96 |
# File 'lib/cmdx/configuration.rb', line 94 def backtrace @backtrace end |
#backtrace_cleaner ⇒ Proc?
Returns the proc used to clean backtraces before logging.
104 105 106 |
# File 'lib/cmdx/configuration.rb', line 104 def backtrace_cleaner @backtrace_cleaner end |
#callbacks ⇒ CallbackRegistry
Returns the callback registry for task lifecycle hooks.
33 34 35 |
# File 'lib/cmdx/configuration.rb', line 33 def callbacks @callbacks end |
#coercions ⇒ CoercionRegistry
Returns the coercion registry for type conversions.
43 44 45 |
# File 'lib/cmdx/configuration.rb', line 43 def coercions @coercions end |
#exception_handler ⇒ Proc?
Returns the proc called when exceptions occur during execution.
114 115 116 |
# File 'lib/cmdx/configuration.rb', line 114 def exception_handler @exception_handler end |
#logger ⇒ Logger
Returns the logger instance for CMDx operations.
84 85 86 |
# File 'lib/cmdx/configuration.rb', line 84 def logger @logger end |
#middlewares ⇒ MiddlewareRegistry
Returns the middleware registry for task execution.
23 24 25 |
# File 'lib/cmdx/configuration.rb', line 23 def middlewares @middlewares end |
#rollback_on ⇒ Array<String>
Returns the statuses that trigger a task execution rollback.
124 125 126 |
# File 'lib/cmdx/configuration.rb', line 124 def rollback_on @rollback_on end |
#task_breakpoints ⇒ Array<String>
Returns the breakpoint statuses for task execution interruption.
63 64 65 |
# File 'lib/cmdx/configuration.rb', line 63 def task_breakpoints @task_breakpoints end |
#validators ⇒ ValidatorRegistry
Returns the validator registry for attribute validation.
53 54 55 |
# File 'lib/cmdx/configuration.rb', line 53 def validators @validators end |
#workflow_breakpoints ⇒ Array<String>
Returns the breakpoint statuses for workflow execution interruption.
74 75 76 |
# File 'lib/cmdx/configuration.rb', line 74 def workflow_breakpoints @workflow_breakpoints end |
Instance Method Details
#to_h ⇒ Hash{Symbol => Object}
Converts the configuration to a hash representation.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/cmdx/configuration.rb', line 171 def to_h { middlewares: @middlewares, callbacks: @callbacks, coercions: @coercions, validators: @validators, task_breakpoints: @task_breakpoints, workflow_breakpoints: @workflow_breakpoints, rollback_on: @rollback_on, backtrace: @backtrace, backtrace_cleaner: @backtrace_cleaner, exception_handler: @exception_handler, logger: @logger } end |