Class: Synthra::Behaviors::Deprecated
- Defined in:
- lib/synthra/behaviors/deprecated.rb
Overview
Emits deprecation warnings during data generation
The Deprecated behavior is used to mark schemas as deprecated. When data is generated from a deprecated schema, a warning is logged/printed to alert developers.
Instance Method Summary collapse
-
#apply(result, context = nil) ⇒ Object
Apply the deprecation warning.
-
#build_warning_message(schema_name) ⇒ String
private
Build the warning message.
-
#emit_warning(context) ⇒ void
private
Emit the deprecation warning.
Constructor Details
This class inherits a constructor from Synthra::Behaviors::Base
Instance Method Details
#apply(result, context = nil) ⇒ Object
Apply the deprecation warning
Emits a warning message about the deprecated schema. The warning is sent to Synthra.logger if available, otherwise to $stderr.
59 60 61 62 |
# File 'lib/synthra/behaviors/deprecated.rb', line 59 def apply(result, context = nil) emit_warning(context) result end |
#build_warning_message(schema_name) ⇒ String (private)
Build the warning message
91 92 93 94 95 |
# File 'lib/synthra/behaviors/deprecated.rb', line 91 def (schema_name) deprecation_note = value.is_a?(String) ? value : "This schema is deprecated" "DEPRECATED: Schema '#{schema_name}' - #{deprecation_note}" end |
#emit_warning(context) ⇒ void (private)
This method returns an undefined value.
Emit the deprecation warning
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/synthra/behaviors/deprecated.rb', line 73 def emit_warning(context) schema_name = context&.instance_variable_get(:@schema_name) || "Unknown" = (schema_name) if Synthra.configuration.logger Synthra.configuration.logger.warn() else warn "[Synthra] #{}" end end |