Module: CMDx::Deprecator
Overview
Handles deprecation warnings and restrictions for tasks.
The Deprecator module provides functionality to restrict usage of deprecated tasks based on configuration settings. It supports different deprecation behaviors including warnings, logging, and errors.
Instance Method Summary collapse
-
#restrict(task) ⇒ Object
Restricts task usage based on deprecation settings.
Instance Method Details
#restrict(task) ⇒ Object
Restricts task usage based on deprecation settings.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cmdx/deprecator.rb', line 63 def restrict(task) setting = task.class.settings.deprecate return unless setting case type = EVAL.call(task, setting) when NilClass, FalseClass then nil # Do nothing when TrueClass, RAISE_REGEXP then raise DeprecationError, "#{task.class.name} usage prohibited" when LOG_REGEXP then task.logger.warn { "DEPRECATED: migrate to a replacement or discontinue use" } when WARN_REGEXP then warn("[#{task.class.name}] DEPRECATED: migrate to a replacement or discontinue use", category: :deprecated) else raise "unknown deprecation type #{type.inspect}" end end |