Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom Marshal encoder/decoder for StripeObject #592

Merged
merged 1 commit into from
Oct 13, 2017

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Oct 13, 2017

Backtracks a little bit #586 by bringing back custom StripeObject
encoding and decoding methods for Ruby's Marshal. These work by just
persisting values and some opts, and skipping everything else. It's
mostly the same as what we had before, but implemented a little more
cleanly so that we don't actually need to invoke Marshal anywhere
ourselves.

In #586 we still managed to remove all the uses of Marshal in our own
codebase to make the linter happy. Even though we wouldn't recommend the
use of Marshal, this code at least enables it for anyone using a Rails
cache or similar mechanism.

Addresses #90.

@brandur-stripe
Copy link
Contributor

r? @ob-stripe

@@ -410,5 +410,18 @@ class StripeObjectTest < Test::Unit::TestCase
end
assert_match(/\(object\).foo = nil/, e.message)
end

should "marshal and unmarshal using custom encoder and decoer" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo here ("decoer")

Copy link
Contributor

@brandur-stripe brandur-stripe Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arg, thanks. Fixed and commit amended.

@brandur-stripe brandur-stripe force-pushed the brandur-reimplement-custom-marshal branch from 2fb50a5 to 0a1d418 Compare October 13, 2017 16:24
@ob-stripe
Copy link
Contributor

lgtm!

Backtracks a little bit #586 by bringing back custom `StripeObject`
encoding and decoding methods for Ruby's `Marshal`. These work by just
persisting values and some opts, and skipping everything else. It's
mostly the same as what we had before, but implemented a little more
cleanly so that we don't actually need to invoke `Marshal` anywhere
ourselves.

In #586 we still managed to remove all the uses of `Marshal` in our own
codebase to make the linter happy. Even though we wouldn't recommend the
use of `Marshal`, this code at least enables it for anyone using a Rails
cache or similar mechanism.

Addresses #90.
@brandur-stripe brandur-stripe force-pushed the brandur-reimplement-custom-marshal branch from 0a1d418 to 91099f9 Compare October 13, 2017 16:31
@brandur-stripe
Copy link
Contributor

Thanks OB!

@brandur-stripe brandur-stripe merged commit f543771 into master Oct 13, 2017
@brandur-stripe brandur-stripe deleted the brandur-reimplement-custom-marshal branch October 13, 2017 16:52
@brandur-stripe
Copy link
Contributor

Released as 3.5.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants