Class: ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy
- Inherits:
-
DeprecationProxy
- Object
- DeprecationProxy
- ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/deprecation/proxy_wrappers.rb
Overview
DeprecatedInstanceVariableProxy transforms an instance variable into a deprecated one. It takes an instance of a class, a method on that class and an instance variable. It optionally takes a deprecator as the last argument. The deprecator defaults to ActiveSupport::Deprecator
if none is specified.
class Example
def initialize
@request = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :request, :@request)
@_request = :special_request
end
def request
@_request
end
def old_request
@request
end
end
example = Example.new
# => #<Example:0x007fb9b31090b8 @_request=:special_request, @request=:special_request>
example.old_request.to_s
# => DEPRECATION WARNING: @request is deprecated! Call request.to_s instead of
@request.to_s
(Backtrace information…)
"special_request"
example.request.to_s
# => "special_request"
Instance Method Summary collapse
-
#initialize(instance, method, var = "@#{method}", deprecator = ActiveSupport::Deprecation.instance) ⇒ DeprecatedInstanceVariableProxy
constructor
A new instance of DeprecatedInstanceVariableProxy.
Methods inherited from DeprecationProxy
Constructor Details
#initialize(instance, method, var = "@#{method}", deprecator = ActiveSupport::Deprecation.instance) ⇒ DeprecatedInstanceVariableProxy
Returns a new instance of DeprecatedInstanceVariableProxy.
89 90 91 92 93 94 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/deprecation/proxy_wrappers.rb', line 89 def initialize(instance, method, var = "@#{method}", deprecator = ActiveSupport::Deprecation.instance) @instance = instance @method = method @var = var @deprecator = deprecator end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveSupport::Deprecation::DeprecationProxy