mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-08-10 00:01:09 -04:00
Use Gem:: deprecation method instead of a custom one
This commit is contained in:
parent
3468698ce9
commit
1a96d7cf8e
@ -64,6 +64,7 @@ require 'stripe/errors/rate_limit_error'
|
||||
|
||||
module Stripe
|
||||
DEFAULT_CA_BUNDLE_PATH = File.dirname(__FILE__) + '/data/ca-certificates.crt'
|
||||
|
||||
@api_base = 'https://api.stripe.com'
|
||||
@connect_base = 'https://connect.stripe.com'
|
||||
@uploads_base = 'https://uploads.stripe.com'
|
||||
@ -207,10 +208,12 @@ module Stripe
|
||||
|
||||
# DEPRECATED. Use `Util#encode_parameters` instead.
|
||||
def self.uri_encode(params)
|
||||
Stripe::Util.warn_deprecated("Stripe.uri_encode",
|
||||
:extra => "Use Stripe::Util#encode_parameters instead.")
|
||||
Util.encode_parameters(params)
|
||||
end
|
||||
class << self
|
||||
extend Gem::Deprecate
|
||||
deprecate :uri_encode, "Stripe::Util#encode_parameters", 2016, 01
|
||||
end
|
||||
|
||||
def self.request_headers(api_key)
|
||||
headers = {
|
||||
|
@ -50,11 +50,10 @@ module Stripe
|
||||
# Please don't use this method. If you're trying to do mass assignment, try
|
||||
# #initialize_from instead.
|
||||
def refresh_from(values, opts, partial=false)
|
||||
Stripe::Util.warn_deprecated("#refresh_from",
|
||||
:extra => "If you're trying to perform mass-assignment, please consider " +
|
||||
"using #update_attributes instead.")
|
||||
initialize_from(values, opts, partial)
|
||||
end
|
||||
extend Gem::Deprecate
|
||||
deprecate :refresh_from, "#update_attributes", 2016, 01
|
||||
|
||||
# Mass assigns attributes on the model.
|
||||
def update_attributes(values)
|
||||
|
@ -181,16 +181,5 @@ module Stripe
|
||||
raise TypeError.new("api_key must be a string") unless key.is_a?(String)
|
||||
key
|
||||
end
|
||||
|
||||
def self.warn_deprecated(name, options = {})
|
||||
# should not trigger on $VERBOSE = nil (false is "level 1", true is
|
||||
# "level 2")
|
||||
if $VERBOSE != nil
|
||||
message = "Warning (stripe): #{name} is deprecated and will be " +
|
||||
"removed in a future version."
|
||||
message += " " + options[:extra] if options[:extra]
|
||||
$stderr.puts(message)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -71,32 +71,5 @@ module Stripe
|
||||
assert_raise { Stripe::Util.normalize_opts(nil) }
|
||||
assert_raise { Stripe::Util.normalize_opts(:api_key => nil) }
|
||||
end
|
||||
|
||||
should "#warn_deprecated produces a deprecation warning" do
|
||||
old_stderr = $stderr
|
||||
$stderr = StringIO.new
|
||||
begin
|
||||
Stripe::Util.warn_deprecated("#refresh_from", :extra => "Don't use it.")
|
||||
message = "Warning (stripe): #refresh_from is deprecated and will be " +
|
||||
"removed in a future version. Don't use it.\n"
|
||||
assert_equal message, $stderr.string
|
||||
ensure
|
||||
$stderr = old_stderr
|
||||
end
|
||||
end
|
||||
|
||||
should "#warn_deprecated is silent on $VERBOSE = nil" do
|
||||
old_stderr = $stderr
|
||||
old_verbose = $VERBOSE
|
||||
$stderr = StringIO.new
|
||||
$VERBOSE = nil
|
||||
begin
|
||||
Stripe::Util.warn_deprecated("#refresh_from", :extra => "Don't use it.")
|
||||
assert_equal "", $stderr.string
|
||||
ensure
|
||||
$stderr = old_stderr
|
||||
$VERBOSE = old_verbose
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user