Module: SimpleEnum::Mongoid

Defined in:
lib/simple_enum/mongoid.rb

Overview

Enables support for mongoid, also automatically creates the requested field.

class Person
  include Mongoid::Document
  include SimpleEnum::Mongoid

  field :name
  as_enum :gender, [:female, :male]
end

When no field is requested:

field :gender_cd, type: Integer
as_enum :gender, [:female, :male], field: false

or custom field options (like e.g. type want to be passed):

as_enum :gender, [:female, :male], field: { type: Integer }

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


26
27
28
29
30
# File 'lib/simple_enum/mongoid.rb', line 26

def self.included(base)
  base.extend SimpleEnum::Attribute
  base.extend SimpleEnum::Translation
  base.extend SimpleEnum::Mongoid::ClassMethods
end