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

Add dig and fetch to Sawyer::Resource #74

Merged
merged 1 commit into from Jun 7, 2022

Conversation

mrpinsky
Copy link
Contributor

@mrpinsky mrpinsky commented Jun 6, 2022

These convenience methods make it easier to work with Resources as a consumer, especially when they come from APIs that have a lot of nesting. My particular motivation comes from using Octokit, which returns Sawyer::Resources, and I routinely try to dig or fetch from them, at which point my code blows up, and I don't want to convert the whole thing to a hash to get just the one bit of data I need.

Supporting these methods, in addition to [], []=, each, and all the other enumerable methods, allows consumers to treat a Sawyer::Resource effectively as a Hash for the attributes without having to convert it to one and lose the extra behavior that the Resource provides.

These convenience methods make it easier to work with `Resource`s as a
consumer, especially when they come from APIs that have a lot of
nesting.

Supporting these methods, in addition to `[]`, `[]=`, `each`, and all
the other enumerable methods, allows consumers to treat a
`Sawyer::Resource` effectively as a Hash for the attributes without
having to convert it to one and lose the extra behavior that the
`Resource` provides.
Copy link
Member

@iMacTia iMacTia left a comment

Choose a reason for hiding this comment

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

This looks like a great addition, useful and test-covered 👍

@iMacTia iMacTia merged commit 84a67e7 into lostisland:master Jun 7, 2022
@mrpinsky mrpinsky deleted the dig-fetch branch June 7, 2022 17:57
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.

None yet

2 participants