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

Improve result querying #38

Merged
merged 2 commits into from
Mar 16, 2024
Merged

Improve result querying #38

merged 2 commits into from
Mar 16, 2024

Conversation

serradura
Copy link
Member

Added

  • Add the BCDD::Success and BCDD::Failure modules. They are key to checking whether a result is a success or a failure independently of whether it is a BCDD::Result or a BCDD::Context.
  • Add BCDD::Result#type? to check if the given type is the result type.
  • Add BCDD::Result#is? as an alias for BCDD::Result#type?.
  • Add BCDD::Result#method_missing to allow the type checking through method calls. For example, result.ok? will check if the result type is :ok.

Note: All the methods above are available for the BCDD::Context as well.

Changed

  • (BREAKING) Change BCDD::Result#deconstruct_keys to return a hash with the keys :type and :value when one of these keys is present. Otherwise, it will return the value itself.

@serradura serradura self-assigned this Mar 16, 2024
@serradura serradura marked this pull request as ready for review March 16, 2024 12:19
@serradura serradura added this to the 1.0.0 milestone Mar 16, 2024
@serradura serradura merged commit 64bab97 into main Mar 16, 2024
6 checks passed
@serradura serradura deleted the feat/improve-result-querying branch March 16, 2024 12:19
@serradura serradura added the enhancement New feature or request label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant