Module: SimpleEnum::Mongoid::ClassMethods
- Defined in:
- lib/simple_enum/mongoid.rb
Instance Method Summary collapse
-
#as_enum(name, values, options = {}) ⇒ Object
Wrap method chain to create mongoid field and additional column options.
Instance Method Details
#as_enum(name, values, options = {}) ⇒ Object
Wrap method chain to create mongoid field and additional column options
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/simple_enum/mongoid.rb', line 35 def as_enum(name, values, = {}) = .delete(:field) enum = super accessor = send("#{name.to_s.pluralize}_accessor") unless === false ||= SimpleEnum.field field(accessor.source, ) if end enum end |