Class: Spree::DeprecatedInstanceVariableProxy
- Inherits:
-
ActiveSupport::Deprecation::DeprecationProxy
- Object
- ActiveSupport::Deprecation::DeprecationProxy
- Spree::DeprecatedInstanceVariableProxy
- Defined in:
- lib/spree/deprecated_instance_variable_proxy.rb
Overview
This DeprecatedInstanceVariableProxy transforms instance variable to deprecated instance variable.
It differs from ActiveSupport::DeprecatedInstanceVariableProxy since it allows to define a custom message.
class Example
def initialize(deprecator)
@request = Spree::DeprecatedInstanceVariableProxy.new(self, :request, :@request, deprecator, "Please, do not use this thing.")
@_request = :a_request
end
def request
@_request
end
def old_request
@request
end
end
When someone execute any method on @request variable this will trigger warn
method on deprecator_instance
and will fetch @_request
variable via request
method and execute the same method on non-proxy instance variable.
Default deprecator is Spree.deprecator
.
Instance Method Summary collapse
-
#initialize(instance, method_or_var, var = "@#{method}", deprecator = Spree.deprecator, message = nil) ⇒ DeprecatedInstanceVariableProxy
constructor
A new instance of DeprecatedInstanceVariableProxy.
Constructor Details
#initialize(instance, method_or_var, var = "@#{method}", deprecator = Spree.deprecator, message = nil) ⇒ DeprecatedInstanceVariableProxy
Returns a new instance of DeprecatedInstanceVariableProxy.
34 35 36 37 38 39 40 |
# File 'lib/spree/deprecated_instance_variable_proxy.rb', line 34 def initialize(instance, method_or_var, var = "@#{method}", deprecator = Spree.deprecator, = nil) @instance = instance @method_or_var = method_or_var @var = var @deprecator = deprecator @message = end |