mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-09-22 00:00:31 -04:00
use _dump and self._load instead of marshal_*
This commit is contained in:
parent
02b40e6637
commit
7ec8a12dff
@ -102,17 +102,18 @@ module Stripe
|
||||
@values.each(&blk)
|
||||
end
|
||||
|
||||
def marshal_dump
|
||||
@values
|
||||
def _dump(level)
|
||||
[Marshal.dump(@values), @api_key].join("--::--")
|
||||
end
|
||||
|
||||
def marshal_load(values)
|
||||
@values = values
|
||||
def self._load(args)
|
||||
hash = args.split("--::--")
|
||||
construct_from(Marshal.load(hash[0]), hash[1])
|
||||
end
|
||||
|
||||
if RUBY_VERSION < '1.9.2'
|
||||
def respond_to?(symbol)
|
||||
@values && @values.has_key?(symbol) || super
|
||||
@values.has_key?(symbol) || super
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,10 +10,11 @@ module Stripe
|
||||
end
|
||||
|
||||
should "marshal a stripe object correctly" do
|
||||
obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' })
|
||||
obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' }, 'apikey')
|
||||
m = Marshal.load(Marshal.dump(obj))
|
||||
assert_equal m.id, 1
|
||||
assert_equal m.name, 'Stripe'
|
||||
assert_equal m.api_key, 'apikey'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user