【文件属性】:
文件名称:mongoid_enumerable:Mongoid 可枚举
文件大小:12KB
文件格式:ZIP
更新时间:2021-05-31 05:54:06
ruby status mongoid mongodb enum
Mongoid 可枚举
在 Mongoid 文档中定义可枚举字段。
安装
将此行添加到应用程序的 Gemfile 中:
gem 'mongoid_enumerable'
然后执行:
$ bundle
或者自己安装:
$ gem install mongoid_enumerable
用法
只需在您的文档中包含MongoidEnumerable 。 添加enumerable后:
字段名称
具有可能值的数组
选项( default和/或prefix )
例子:
class Task
include Mongoid :: Document
include MongoidEnumerable
enumerable :status , %w[ completed running failed waiting ] , default : "waiting"
end
【文件预览】:
mongoid_enumerable-master
----.gitignore(126B)
----Guardfile(1KB)
----.rspec(53B)
----bin()
--------setup(131B)
--------console(383B)
----mongoid_enumerable.gemspec(1KB)
----.rubocop.yml(270B)
----.github()
--------workflows()
----spec()
--------spec_helper.rb(484B)
--------mongoid_enumerable_spec.rb(10KB)
----README.md(5KB)
----lib()
--------mongoid_enumerable.rb(2KB)
--------mongoid_enumerable()
----Gemfile(205B)
----Rakefile(214B)