Class: VagrantHosts::ConfigBuilder::Model
- Inherits:
-
ConfigBuilder::Model::Provisioner::Base
- Object
- ConfigBuilder::Model::Provisioner::Base
- VagrantHosts::ConfigBuilder::Model
- Defined in:
- lib/vagrant-hosts/config_builder/0_x.rb,
lib/vagrant-hosts/config_builder/1_x.rb
Overview
Instance Attribute Summary collapse
- #add_localhost_hostnames ⇒ Object
- #autoconfigure ⇒ Object
- #change_hostname ⇒ Object
- #exports ⇒ Object
- #hosts ⇒ Object
- #sync_hosts ⇒ Object
Instance Method Summary collapse
- #configure_exports(config, val) ⇒ Object
- #configure_hosts(config, val) ⇒ Object
- #configure_imports(config, val) ⇒ Object
-
#initialize ⇒ Model
constructor
A new instance of Model.
- #to_proc ⇒ Object
Constructor Details
#initialize ⇒ Model
Returns a new instance of Model.
17 18 19 20 21 |
# File 'lib/vagrant-hosts/config_builder/0_x.rb', line 17 def initialize @defaults = { :hosts => [], } end |
Instance Attribute Details
#add_localhost_hostnames ⇒ Object
13 14 15 |
# File 'lib/vagrant-hosts/config_builder/0_x.rb', line 13 def add_localhost_hostnames @add_localhost_hostnames end |
#autoconfigure ⇒ Object
11 12 13 |
# File 'lib/vagrant-hosts/config_builder/0_x.rb', line 11 def autoconfigure @autoconfigure end |
#change_hostname ⇒ Object
23 |
# File 'lib/vagrant-hosts/config_builder/1_x.rb', line 23 def_model_attribute :change_hostname |
#exports ⇒ Object
19 |
# File 'lib/vagrant-hosts/config_builder/1_x.rb', line 19 def_model_attribute :exports |
#hosts ⇒ Object
9 10 11 |
# File 'lib/vagrant-hosts/config_builder/0_x.rb', line 9 def hosts @hosts end |
#sync_hosts ⇒ Object
15 16 17 |
# File 'lib/vagrant-hosts/config_builder/0_x.rb', line 15 def sync_hosts @sync_hosts end |
Instance Method Details
#configure_exports(config, val) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/vagrant-hosts/config_builder/1_x.rb', line 26 def configure_exports(config, val) val.each do |k, v| config.exports[k] ||= [] config.exports[k] += v end end |
#configure_hosts(config, val) ⇒ Object
40 41 42 43 44 |
# File 'lib/vagrant-hosts/config_builder/1_x.rb', line 40 def configure_hosts(config, val) val.each do |(address, aliases)| config.add_host(address, aliases) end end |
#configure_imports(config, val) ⇒ Object
34 35 36 37 |
# File 'lib/vagrant-hosts/config_builder/1_x.rb', line 34 def configure_imports(config, val) config.imports += val config.imports.uniq! end |
#to_proc ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant-hosts/config_builder/0_x.rb', line 23 def to_proc Proc.new do |vm_config| vm_config.provision :hosts do |h_config| h_config.autoconfigure = attr(:autoconfigure) unless attr(:autoconfigure).nil? h_config.add_localhost_hostnames = attr(:add_localhost_hostnames) unless attr(:add_localhost_hostnames).nil? h_config.sync_hosts = attr(:sync_hosts) unless attr(:sync_hosts).nil? attr(:hosts).each do |(address, aliases)| h_config.add_host address, aliases end end end end |