Class: Vagrant::Action::VM::ClearSharedFolders

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/action/vm/clear_shared_folders.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ClearSharedFolders

Returns a new instance of ClearSharedFolders.



5
6
7
8
# File 'lib/vagrant/action/vm/clear_shared_folders.rb', line 5

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
# File 'lib/vagrant/action/vm/clear_shared_folders.rb', line 10

def call(env)
  @env = env

  clear_shared_folders
  @app.call(env)
end

#clear_shared_foldersObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant/action/vm/clear_shared_folders.rb', line 17

def clear_shared_folders
  if @env["vm"].vm.shared_folders.length > 0
    @env.ui.info I18n.t("vagrant.actions.vm.clear_shared_folders.deleting")

    folders = @env["vm"].vm.shared_folders.dup
    folders.each do |shared_folder|
      shared_folder.destroy
    end

    @env["vm"].reload!
  end
end