virtus icon indicating copy to clipboard operation
virtus copied to clipboard

Feature Request: enum-like functionality

Open jasonkarns opened this issue 10 years ago • 4 comments

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?

jasonkarns avatar Aug 03 '15 19:08 jasonkarns

I would also like this feature.

thehappycoder avatar Aug 23 '15 10:08 thehappycoder

@solnic I'd be up for implementing this if it's in scope, as I would like this functionality myself :)

pnomolos avatar Oct 28 '15 18:10 pnomolos

@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

solnic avatar Nov 06 '15 02:11 solnic

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

jasonkarns avatar Mar 25 '16 20:03 jasonkarns