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

Pattern match on object keys for response sub-objects #187

Merged
merged 1 commit into from
Jan 15, 2017

Conversation

begedin
Copy link
Contributor

@begedin begedin commented Jan 15, 2017

This modifies the converter module to pattern match on object keys for sub-hashes, if these are present. It allows us to properly serialize stripe objects such as events, due to these having dynamic relationships (an event can hold any other non-specific stripe object).

It also completely removes the need for the relationships attribute/method on all our modules.

Closes #187

This change puts us in a position where we could similarly do the same for the base object itself, since all Stripe objects have the "object" key. It would remove the need to pass in the module into our Converter.stripe_map_to_struct method. It potentially even could allow us to remove the need to pass in the module into our Request.<action> methods.

Another option this opens is the ability to properly serialize lists. I will create issues for both of these.

assert object_name_to_module("plan") == Stripe.Plan
assert object_name_to_module("subscription") == Stripe.Subscription
assert object_name_to_module("token") == Stripe.Token
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Spacing is a tad off here.

Copy link
Contributor

@joshsmith joshsmith left a comment

Choose a reason for hiding this comment

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

Minor comment here.

@begedin begedin force-pushed the 186-pattern-match-on-object-keys branch from 0e22b8a to 7b0ac4c Compare January 15, 2017 00:51
@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 25.352% when pulling 7b0ac4c on 186-pattern-match-on-object-keys into f29a330 on 2.0.

@begedin begedin merged commit 86f7a9f into 2.0 Jan 15, 2017
@begedin begedin deleted the 186-pattern-match-on-object-keys branch January 15, 2017 02:00
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.

3 participants