mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Remove ActiveModelSerializers.silence_warnings dead code
The ActiveModelSerializers.silence_warnings was used to avoid warnings on the Ruby interpreter when define a private attr_acessor. This method is not used in any part of the code and the recommend way to handle this case is to use protected instead the silence_warnings [1]. This patch remove the method from the project, this way we avoid people using this by mistake. [1]: https://bugs.ruby-lang.org/issues/10967
This commit is contained in:
parent
d8b2b94a22
commit
5fb7cceafb
@ -13,39 +13,6 @@ module ActiveModelSerializers
|
|||||||
autoload :Model
|
autoload :Model
|
||||||
autoload :Callbacks
|
autoload :Callbacks
|
||||||
autoload :Logging
|
autoload :Logging
|
||||||
|
|
||||||
module_function
|
|
||||||
|
|
||||||
# @note
|
|
||||||
# ```ruby
|
|
||||||
# private
|
|
||||||
#
|
|
||||||
# attr_reader :resource, :adapter_opts, :serializer_opts
|
|
||||||
# ```
|
|
||||||
#
|
|
||||||
# Will generate a warning, though it shouldn't.
|
|
||||||
# There's a bug in Ruby for this: https://bugs.ruby-lang.org/issues/10967
|
|
||||||
#
|
|
||||||
# We can use +ActiveModelSerializers.silence_warnings+ as a
|
|
||||||
# 'safety valve' for unfixable or not-worth-fixing warnings,
|
|
||||||
# and keep our app warning-free.
|
|
||||||
#
|
|
||||||
# ```ruby
|
|
||||||
# private
|
|
||||||
#
|
|
||||||
# ActiveModelSerializers.silence_warnings do
|
|
||||||
# attr_reader :resource, :adapter_opts, :serializer_opts
|
|
||||||
# end
|
|
||||||
# ```
|
|
||||||
#
|
|
||||||
# or, as specific stopgap, define the attrs in the protected scope.
|
|
||||||
def silence_warnings
|
|
||||||
verbose = $VERBOSE
|
|
||||||
$VERBOSE = nil
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
$VERBOSE = verbose
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'active_model/serializer'
|
require 'active_model/serializer'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user