use _dump and self._load instead of marshal_*

This commit is contained in:
Andrew Thorp 2014-01-29 07:54:35 -06:00
parent 02b40e6637
commit 7ec8a12dff
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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