Class: Vagrant::Plugin::V2::SyncedFolder::Collection
- Inherits:
-
Hash
- Object
- Hash
- Vagrant::Plugin::V2::SyncedFolder::Collection
- Defined in:
- lib/vagrant/plugin/v2/synced_folder.rb
Instance Method Summary collapse
-
#to_h ⇒ Hash
Converts to a regular Hash and removes plugin instances so the result is ready for serialization.
-
#type(t) ⇒ Vagrant::Plugin::V2::SyncedFolder
Fetch the synced plugin folder of the given type.
-
#types ⇒ Array<Symbol>
Names of synced folder types.
Instance Method Details
#to_h ⇒ Hash
Converts to a regular Hash and removes plugin instances so the result is ready for serialization
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
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 |
#types ⇒ Array<Symbol>
Returns names of synced folder types.
12 13 14 |
# File 'lib/vagrant/plugin/v2/synced_folder.rb', line 12 def types keys end |