forked from solidusio/solidus
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request solidusio#5289 from nebulab/kennyadsl/deprecation-…
…updates Deprecate `Spree::Deprecation` in favor of `Spree.deprecator`
- Loading branch information
Showing
27 changed files
with
108 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/app/views/spree/admin/shared/_product_sub_menu.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/app/views/spree/admin/shared/_promotion_sub_menu.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/app/views/spree/admin/shared/_settings_sub_menu.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/lib/spree/backend_configuration/deprecated_tab_constants.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_support/deprecation' | ||
|
||
module Spree | ||
# 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 <tt>@_request</tt> | ||
# variable via +request+ method and execute the same method on non-proxy | ||
# instance variable. | ||
# | ||
# Default deprecator is <tt>Spree.deprecator</tt>. | ||
class DeprecatedInstanceVariableProxy < ActiveSupport::Deprecation::DeprecationProxy | ||
def initialize(instance, method_or_var, var = "@#{method}", deprecator = Spree.deprecator, message = nil) | ||
@instance = instance | ||
@method_or_var = method_or_var | ||
@var = var | ||
@deprecator = deprecator | ||
@message = message | ||
end | ||
|
||
private | ||
|
||
def target | ||
return @instance.instance_variable_get(@method_or_var) if @instance.instance_variable_defined?(@method_or_var) | ||
|
||
@instance.__send__(@method_or_var) | ||
end | ||
|
||
def warn(callstack, called, args) | ||
message = @message || "#{@var} is deprecated! Call #{@method_or_var}.#{called} instead of #{@var}.#{called}." | ||
message = [message, "Args: #{args.inspect}"].join(" ") unless args.empty? | ||
|
||
@deprecator.warn(message, callstack) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_support/deprecation' | ||
require 'spree/core' | ||
|
||
module Spree | ||
Deprecation = ActiveSupport::Deprecation.new('5.0', 'Solidus') | ||
Deprecation = Spree.deprecator | ||
|
||
# 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 <tt>@_request</tt> | ||
# variable via +request+ method and execute the same method on non-proxy | ||
# instance variable. | ||
# | ||
# Default deprecator is <tt>Spree::Deprecation</tt>. | ||
class DeprecatedInstanceVariableProxy < ActiveSupport::Deprecation::DeprecationProxy | ||
def initialize(instance, method_or_var, var = "@#{method}", deprecator = Spree::Deprecation, message = nil) | ||
@instance = instance | ||
@method_or_var = method_or_var | ||
@var = var | ||
@deprecator = deprecator | ||
@message = message | ||
end | ||
|
||
private | ||
|
||
def target | ||
return @instance.instance_variable_get(@method_or_var) if @instance.instance_variable_defined?(@method_or_var) | ||
|
||
@instance.__send__(@method_or_var) | ||
end | ||
|
||
def warn(callstack, called, args) | ||
message = @message || "#{@var} is deprecated! Call #{@method_or_var}.#{called} instead of #{@var}.#{called}." | ||
message = [message, "Args: #{args.inspect}"].join(" ") unless args.empty? | ||
|
||
@deprecator.warn(message, callstack) | ||
end | ||
end | ||
Spree.deprecator.warn "Spree::Deprecation is deprecated. Please use Spree.deprecator instead.", caller(2) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spree/deprecation' | ||
require 'spree/encryptor' | ||
|
||
module Spree::Preferences | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.