File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ # JSONAPI::CompatibilityHelper
4+ #
5+ # This module provides a version-safe method for issuing deprecation warnings
6+ # that works across multiple versions of Rails (7.x, 8.x, etc).
7+ #
8+ # Usage:
9+ # JSONAPI::CompatibilityHelper.deprecation_warn("Your deprecation message")
10+ #
11+ # The method will use the public `warn` method if available, otherwise it will
12+ # use `send(:warn, ...)` to maintain compatibility with Rails 8+ where `warn`
13+ # is private.
14+ #
15+ # Example:
16+ # JSONAPI::CompatibilityHelper.deprecation_warn("This feature is deprecated.")
17+
18+ module JSONAPI
19+ module CompatibilityHelper
20+ def deprecation_warn ( message )
21+ if ActiveSupport ::Deprecation . respond_to? ( :warn ) && ActiveSupport ::Deprecation . public_method_defined? ( :warn )
22+ ActiveSupport ::Deprecation . warn ( message )
23+ else
24+ ActiveSupport ::Deprecation . send ( :warn , message )
25+ end
26+ end
27+ module_function :deprecation_warn
28+ end
29+ end
You can’t perform that action at this time.
0 commit comments