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)

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

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)

17
18
19
20
21
# File 'lib/vagrant/plugin/v2/synced_folder.rb', line 17

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


9
10
11
# File 'lib/vagrant/plugin/v2/synced_folder.rb', line 9

def types
  keys
end