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

Missing method implementation for Enum.each_value #458

Open
edgarjs opened this issue Jul 18, 2023 · 1 comment
Open

Missing method implementation for Enum.each_value #458

edgarjs opened this issue Jul 18, 2023 · 1 comment

Comments

@edgarjs
Copy link

edgarjs commented Jul 18, 2023

Describe the bug

This is not a bug but a "nice to have". Given an enum type like MyEnum = Types::String.enum('foo', 'bar'), when I want to iterate over the values, I'm doing it with MyEnum.values.each, but it would be nice if the Enum type had the each_value method similar to a Hash object.

To Reproduce

Run the following lines in an IRB session with the dry-types gem installed:

require 'dry-types'

MyEnum = Types::String.enum('foo', 'bar')
MyEnum.each_value { |value| puts value } # Throws a NoMethodError

Expected behavior

It would be nice if Dry::Types::Enum mimics the interface of a Hash object and implements the each_value method.

My environment

  • Affects my production application: YES
  • Ruby version: ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin21]
  • OS: macOS 13.4.1
@CharlieWWW94
Copy link

@edgarjs I have made a PR that implements this method here #471 👍

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

No branches or pull requests

2 participants