virtus
virtus copied to clipboard
Feature Request: enum-like functionality
I would love to specify an attribute (Symbol, most likely), and to specify a defined list of valid values for the symbol. Essentially an enum type with Symbol as the underlying type.
Is this on the roadmap or known to be out of scope? Or potentially already a recommended alternate implementation?
I would also like this feature.
@solnic I'd be up for implementing this if it's in scope, as I would like this functionality myself :)
@pnomolos I don't mind, I'm no longer working on/using virtus O_o Gotta make that official at some point and explain why
I see that this type of behavior ought to be possible with axiom-types, similar to how Axiom::Types::Boolean works:
https://github.com/dkubb/axiom-types/blob/31ff2c7b578438b7cbef6458c43ceda3be4d121c/lib/axiom/types/boolean.rb#L10
But I'm completely lost as to how to specify the type. Do I create a subclass of Axiom::Types::Object? Add #coerce? / any insight @dkubb