mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-05-30 00:00:47 -04:00
Exclude client when dumping objects
This commit is contained in:
parent
eb0883ee75
commit
d3e40bb1de
@ -137,7 +137,12 @@ module Stripe
|
||||
end
|
||||
|
||||
def _dump(level)
|
||||
Marshal.dump([@values, @opts])
|
||||
# The StripeClient instance in @opts is not serializable and is not
|
||||
# really a property of the StripeObject, so we exclude it when
|
||||
# dumping
|
||||
opts = @opts.clone
|
||||
opts.delete(:client)
|
||||
Marshal.dump([@values, opts])
|
||||
end
|
||||
|
||||
def self._load(args)
|
||||
|
@ -36,7 +36,15 @@ module Stripe
|
||||
end
|
||||
|
||||
should "marshal a stripe object correctly" do
|
||||
obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' }, {:api_key => 'apikey'})
|
||||
obj = Stripe::StripeObject.construct_from(
|
||||
{ :id => 1, :name => 'Stripe' },
|
||||
{
|
||||
:api_key => 'apikey',
|
||||
# StripeClient is not serializable and is expected to be removed
|
||||
# when marshalling StripeObjects
|
||||
:client => StripeClient.active_client,
|
||||
}
|
||||
)
|
||||
m = Marshal.load(Marshal.dump(obj))
|
||||
assert_equal 1, m.id
|
||||
assert_equal 'Stripe', m.name
|
||||
|
Loading…
x
Reference in New Issue
Block a user