DataMapper - 鉴别器的类似于枚举的选项标志?
我最近开始在一些项目中使用 DataMapper总的来说,我认为这太棒了。但我对使用它的某个特定方面有疑问。
我知道,如果我有一个带有 Enum 属性的模型(property :whatev, Enum[ :foo, :bar ]
),我可以调用 Model.whatev.options[:flag]< /代码> &返回特定枚举的所有不同可能值。我想知道是否有人知道(或者可以为我指明正确的方向)Discriminator 属性类型是否有类似的内容?
IE。有没有办法调用该特定属性&让它返回各种选项
I have recently started using DataMapper in a few projects & overall I think its just fantastic. But I have a question about using a particular aspect of it.
I know that if I have a model with an Enum property (property :whatev, Enum[ :foo, :bar ]
), I can call Model.whatev.options[:flag]
& get back all of the different possible values for the particular Enum. I am wondering if anyone knows (or could point me in the right direction) if there is something similar for the Discriminator
property type?
ie. is there a way to call that particular property & have it return the various options
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点晚了,但还是到了。给定模型定义,例如:
您可以使用以下命令查看子类:
它返回一个数组:
[Bar, Baz]
。A bit late, but here goes. Given model definitions such as:
You can see the subclasses with:
which returns an array:
[Bar, Baz]
.