Class: Vagrant::Plugin::V2::SyncedFolder::Collection

Inherits:
Hash
  • Object
show all
Defined in:
lib/vagrant/plugin/v2/synced_folder.rb

Instance Method Summary collapse

Instance Method Details

#to_hHash

Converts to a regular Hash and removes plugin instances so the result is ready for serialization

Returns:

  • (Hash)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vagrant/plugin/v2/synced_folder.rb', line 31

def to_h
  c = lambda do |h|
    h.keys.each do |k|
      if h[k].is_a?(Hash)
        h[k] = c.call(h[k].to_h.clone)
      end
    end
    h
  end
  h = c.call(super)
  h.values.each do |f|
    f.values.each do |g|
      g.delete(:plugin)
    end
  end
  h
end

#type(t) ⇒ Vagrant::Plugin::V2::SyncedFolder

Fetch the synced plugin folder of the given type

Parameters:

  • t (Symbol)

    Synced folder type

Returns:

Raises:

  • (KeyError)


20
21
22
23
24
# File 'lib/vagrant/plugin/v2/synced_folder.rb', line 20

def type(t)
  f = detect { |k, _| k.to_sym == t.to_sym }.last
  raise KeyError, "Unknown synced folder type" if !f
  f.values.first[:plugin]
end

#typesArray<Symbol>

Returns names of synced folder types.

Returns:

  • (Array<Symbol>)

    names of synced folder types



12
13
14
# File 'lib/vagrant/plugin/v2/synced_folder.rb', line 12

def types
  keys
end