dry-types
dry-types copied to clipboard
Missing method implementation for `Enum.each_value`
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
@edgarjs I have made a PR that implements this method here #471 :+1: