Module: Mongoid::Document::ClassMethods
- Defined in:
- lib/mumuki/classroom/models/concerns/extensions.rb
Instance Method Summary collapse
- #create_index(*args) ⇒ Object
- #drop_index(index_name) ⇒ Object
- #has_index_named?(index_name) ⇒ Boolean
Instance Method Details
#create_index(*args) ⇒ Object
14 15 16 17 |
# File 'lib/mumuki/classroom/models/concerns/extensions.rb', line 14 def create_index(*args) index *args Mumuki::Classroom.register_index! self end |
#drop_index(index_name) ⇒ Object
19 20 21 |
# File 'lib/mumuki/classroom/models/concerns/extensions.rb', line 19 def drop_index(index_name) collection.indexes.drop_one(index_name) if has_index_named?(index_name) end |
#has_index_named?(index_name) ⇒ Boolean
23 24 25 |
# File 'lib/mumuki/classroom/models/concerns/extensions.rb', line 23 def has_index_named?(index_name) collection.indexes.any? { |spec| spec['name'] == index_name } end |