Module: CMDx

Extended by:
CMDx
Included in:
CMDx
Defined in:
lib/cmdx/railtie.rb,
lib/cmdx.rb,
lib/cmdx/task.rb,
lib/cmdx/chain.rb,
lib/cmdx/errors.rb,
lib/cmdx/faults.rb,
lib/cmdx/locale.rb,
lib/cmdx/result.rb,
lib/cmdx/context.rb,
lib/cmdx/version.rb,
lib/cmdx/executor.rb,
lib/cmdx/pipeline.rb,
lib/cmdx/workflow.rb,
lib/cmdx/attribute.rb,
lib/cmdx/deprecator.rb,
lib/cmdx/exceptions.rb,
lib/cmdx/identifier.rb,
lib/cmdx/utils/call.rb,
lib/cmdx/utils/format.rb,
lib/cmdx/configuration.rb,
lib/cmdx/coercions/date.rb,
lib/cmdx/coercions/hash.rb,
lib/cmdx/coercions/time.rb,
lib/cmdx/attribute_value.rb,
lib/cmdx/coercions/array.rb,
lib/cmdx/coercions/float.rb,
lib/cmdx/utils/condition.rb,
lib/cmdx/coercions/string.rb,
lib/cmdx/coercions/symbol.rb,
lib/cmdx/callback_registry.rb,
lib/cmdx/coercion_registry.rb,
lib/cmdx/coercions/boolean.rb,
lib/cmdx/coercions/complex.rb,
lib/cmdx/coercions/integer.rb,
lib/cmdx/validators/format.rb,
lib/cmdx/validators/length.rb,
lib/cmdx/attribute_registry.rb,
lib/cmdx/coercions/rational.rb,
lib/cmdx/log_formatters/raw.rb,
lib/cmdx/validator_registry.rb,
lib/cmdx/validators/numeric.rb,
lib/cmdx/coercions/date_time.rb,
lib/cmdx/log_formatters/json.rb,
lib/cmdx/log_formatters/line.rb,
lib/cmdx/middleware_registry.rb,
lib/cmdx/middlewares/runtime.rb,
lib/cmdx/middlewares/timeout.rb,
lib/cmdx/validators/presence.rb,
lib/cmdx/validators/exclusion.rb,
lib/cmdx/validators/inclusion.rb,
lib/cmdx/coercions/big_decimal.rb,
lib/cmdx/middlewares/correlate.rb,
lib/cmdx/log_formatters/logstash.rb,
lib/cmdx/log_formatters/key_value.rb

Defined Under Namespace

Modules: Coercions, Deprecator, Identifier, Locale, LogFormatters, Middlewares, Utils, Validators, Workflow Classes: Attribute, AttributeRegistry, AttributeValue, CallbackRegistry, Chain, CoercionRegistry, Configuration, Context, Errors, Executor, Fault, MiddlewareRegistry, Pipeline, Railtie, Result, Task, ValidatorRegistry

Constant Summary collapse

SkipFault =

Fault raised when a task is intentionally skipped during execution.

This fault occurs when a task determines it should not execute based on its current context or conditions. Skipped tasks are not considered failures but rather intentional bypasses of task execution logic.

Class.new(Fault)
FailFault =

Fault raised when a task execution fails due to errors or validation failures.

This fault occurs when a task encounters an error condition, validation failure, or any other condition that prevents successful completion. Failed tasks indicate that the intended operation could not be completed successfully.

Class.new(Fault)
VERSION =

Returns the version of the CMDx gem.

Returns:

  • (String)

    the version of the CMDx gem

"1.11.0"
Error =

Base exception class for all CMDx-related errors.

This serves as the root exception class for all errors raised by the CMDx framework. It inherits from StandardError and provides a common base for handling CMDx-specific exceptions.

Class.new(StandardError)
CoercionError =

Raised when attribute coercion fails during task execution.

This error occurs when a attribute value cannot be converted to the expected type using the registered coercion handlers. It indicates that the provided value is incompatible with the attribute’s defined type.

Class.new(Error)
DeprecationError =

Raised when a deprecated task is used.

This error occurs when a deprecated task is called. It indicates that the task is no longer supported and should be replaced with a newer alternative.

Class.new(Error)
UndefinedMethodError =

Raised when an abstract method is called without being implemented.

This error occurs when a subclass fails to implement required abstract methods such as ‘task’ in tasks. It indicates incomplete implementation of required functionality.

Class.new(Error)
ValidationError =

Raised when attribute validation fails during task execution.

This error occurs when a attribute value doesn’t meet the validation criteria defined by the validator. It indicates that the provided value violates business rules or data integrity constraints.

Class.new(Error)
TimeoutError =

Error raised when task execution exceeds the configured timeout limit.

This error occurs when a task takes longer to execute than the specified time limit. Timeout errors are raised by Ruby’s Timeout module and are caught by the middleware to properly fail the task with timeout information.

Class.new(Interrupt)

Instance Method Summary collapse

Instance Method Details

#configurationConfiguration

Returns the global configuration instance, creating it if it doesn’t exist.

Examples:

config = CMDx.configuration
config.middlewares # => #<MiddlewareRegistry>

Returns:



200
201
202
203
204
# File 'lib/cmdx/configuration.rb', line 200

def configuration
  return @configuration if @configuration

  @configuration ||= Configuration.new
end

#configure {|Configuration| ... } ⇒ Configuration

Configures CMDx using a block that receives the configuration instance.

Examples:

CMDx.configure do |config|
  config.task_breakpoints = ["failed", "skipped"]
  config.logger.level = Logger::DEBUG
end

Yields:

Returns:

Raises:

  • (ArgumentError)

    when no block is provided



221
222
223
224
225
226
227
# File 'lib/cmdx/configuration.rb', line 221

def configure
  raise ArgumentError, "block required" unless block_given?

  config = configuration
  yield(config)
  config
end

#gem_pathPathname

Returns the path to the CMDx gem.

Examples:

CMDx.gem_path # => Pathname.new("/path/to/cmdx")

Returns:

  • (Pathname)

    the path to the CMDx gem



28
29
30
# File 'lib/cmdx.rb', line 28

def gem_path
  @gem_path ||= Pathname.new(__dir__).parent
end

#reset_configuration!Configuration

Resets the global configuration to a new instance with default values.

Examples:

CMDx.reset_configuration!
# Configuration is now reset to defaults

Returns:



238
239
240
# File 'lib/cmdx/configuration.rb', line 238

def reset_configuration!
  @configuration = Configuration.new
end