Module: VagrantPlugins::Dotvm::Injector::AbstractInjector

Included in:
AuthorizedKey, Host, Instance, Machine, Network, Project, Provision, Route, SharedFolder
Defined in:
lib/vagrant-dotvm/injector/abstractinjector.rb

Overview

Helper functions used by injectors

Class Method Summary collapse

Class Method Details

.generate_hash(source, options) ⇒ Hash

Extracts specified options from source and return them as hash.

Parameters:

  • source (Object) —

    Object to extract data from

  • options (Array) —

    List of options to be extraced

Returns:

  • (Hash) —

    Extracted data



13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-dotvm/injector/abstractinjector.rb', line 13

def generate_hash(source, options)
  hash = {}

  options.each do |opt|
    val = source.send(opt)
    hash[opt] = val unless val.nil?
  end

  hash
end

.rewrite_options(source, target, options) ⇒ Object

Rewrite options from source to target.

Parameters:

  • source (Object) —

    Object to rewrite data from

  • target (Object) —

    Object to rewrite data to

  • options (Array) —

    List of options to be rewritten



29
30
31
32
33
34
# File 'lib/vagrant-dotvm/injector/abstractinjector.rb', line 29

def rewrite_options(source, target, options)
  options.each do |opt|
    val = source.send(opt)
    target.send("#{opt}=", val) unless val.nil?
  end
end