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 some Hash's methods to BCDD::Context #41

Merged
merged 3 commits into from
Mar 25, 2024

Conversation

serradura
Copy link
Member

Add some Hash's methods to BCDD::Context. They are:

  • #slice to extract only the desired keys.
  • #[], #dig, #fetch to access the values.
  • #values_at and #fetch_values to get the values of the desired keys.
result = BCDD::Context::Success(:ok, a: 1, b: 2, c: {d: 4})

result[:a]         # 1
result.fetch(:a)   # 1
result.dig(:c, :d) # 4

result.slice(:a, :b) # {:a=>1, :b=>2}

result.values_at(:a, :b) # [1, 2]
result.fetch_values(:a, :b) # [1, 2]

These methods are available for BCDD::Context::Success and BCDD::Context::Failure instances.

@serradura serradura added the enhancement New feature or request label Mar 25, 2024
@serradura serradura self-assigned this Mar 25, 2024
@serradura serradura added this to the 1.1.0 milestone Mar 25, 2024
@serradura serradura merged commit 7bf8ba6 into main Mar 25, 2024
6 checks passed
@serradura serradura deleted the feat/add-hash-methods-to-bcdd-context branch March 25, 2024 13:15
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