Module: Mongoid::Indexing
- Defined in:
- lib/mongoid/indexing.rb
Class Attribute Summary collapse
-
.logging ⇒ Object
writeonly
Sets the attribute logging.
Class Method Summary collapse
- .create_indexes(models_paths = nil) ⇒ Object
- .log? ⇒ Boolean
- .log_off! ⇒ Object
- .log_on! ⇒ Object
- .rails_models_paths ⇒ Object
- .remove_indexes(models_paths = nil) ⇒ Object
Class Attribute Details
.logging=(value) ⇒ Object (writeonly)
Sets the attribute logging
4 5 6 |
# File 'lib/mongoid/indexing.rb', line 4 def logging=(value) @logging = value end |
Class Method Details
.create_indexes(models_paths = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mongoid/indexing.rb', line 18 def create_indexes models_paths = nil models_paths ||= rails_models_paths raise ArgumentError, "No model paths for creating mongoid indexes" if models_paths.blank? "CREATE INDEXES: #{models_paths}" models_paths.each do |path| ::Rails::Mongoid.create_indexes("#{path}/**/*.rb") end end |
.log? ⇒ Boolean
14 15 16 |
# File 'lib/mongoid/indexing.rb', line 14 def log? @logging end |
.log_off! ⇒ Object
10 11 12 |
# File 'lib/mongoid/indexing.rb', line 10 def log_off! @logging = false end |
.log_on! ⇒ Object
6 7 8 |
# File 'lib/mongoid/indexing.rb', line 6 def log_on! @logging = true end |
.rails_models_paths ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/mongoid/indexing.rb', line 40 def rails_models_paths engines_models_paths = Rails.application.railties.engines.map do |engine| engine.paths["app/models"]. end root_models_paths = Rails.application.paths["app/models"] engines_models_paths.push(root_models_paths).flatten end |
.remove_indexes(models_paths = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mongoid/indexing.rb', line 29 def remove_indexes models_paths = nil models_paths ||= rails_models_paths raise ArgumentError, "No model paths for creating mongoid indexes" if models_paths.blank? "REMOVING INDEXES: #{models_paths}" models_paths.each do |path| ::Rails::Mongoid.remove_indexes("#{path}/**/*.rb") end end |