Class: MongoidOccurrenceViews::DestroyMongodbView

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid_occurrence_views/destroy_mongodb_view.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ DestroyMongodbView

Returns a new instance of DestroyMongodbView.



3
4
5
# File 'lib/mongoid_occurrence_views/destroy_mongodb_view.rb', line 3

def initialize(name:)
  @name = name
end

Class Method Details

.call(*args) ⇒ Object



7
8
9
# File 'lib/mongoid_occurrence_views/destroy_mongodb_view.rb', line 7

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
# File 'lib/mongoid_occurrence_views/destroy_mongodb_view.rb', line 11

def call
  Mongoid.clients.each do |client_name, _|
    client = Mongoid.client(client_name)
    next unless client.collections.map(&:name).include?(name)
    client.command(drop: name)
  end
end