Module: MongoODM::Document::Indexes::ClassMethods

Defined in:
lib/mongo_odm/document/indexes.rb

Instance Method Summary collapse

Instance Method Details

#create_indexesObject



45
46
47
# File 'lib/mongo_odm/document/indexes.rb', line 45

def create_indexes
  indexes.each {|index| create_index index.spec, index.opts }
end

#index(spec, opts = {}) ⇒ Object



38
39
40
41
42
43
# File 'lib/mongo_odm/document/indexes.rb', line 38

def index(spec, opts = {})
  new_index = Index.new(spec, opts)
  indexes << new_index
  MongoODM.add_index_class(self)
  new_index
end

#indexesObject



34
35
36
# File 'lib/mongo_odm/document/indexes.rb', line 34

def indexes
  @indexes ||= []
end

#inherited(subclass) ⇒ Object



29
30
31
32
# File 'lib/mongo_odm/document/indexes.rb', line 29

def inherited(subclass)
  super
  indexes.concat(subclass.indexes)
end