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.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cmdx/deprecator.rb', line 51 def restrict(task) type = EVAL.call(task, task.class.settings[:deprecate]) case type when NilClass, FalseClass # Do nothing when TrueClass, /raise/ then raise DeprecationError, "#{task.class.name} usage prohibited" when /log/ then task.logger.warn { "DEPRECATED: migrate to a replacement or discontinue use" } when /warn/ then warn("[#{task.class.name}] DEPRECATED: migrate to a replacement or discontinue use", category: :deprecated) else raise "unknown deprecation type #{type.inspect}" end end |