-module Vagrant
- module Provisioners
- class CopyMyConf < Base
- class Config < Vagrant::Config::Base
- def self.all_attributes
- [:ssh, :vim, :git]
- end
- attr_accessor :user_home
+require_relative "git"
+require_relative "ssh"
+require_relative "vim"
- all_attributes.each do |attr|
- define_method(attr) do
- instance_variable_get_or_set(attr, CopyMyConf.const_get("#{attr.capitalize}").new)
- end
- end
+module CopyMyConf
+ class Config < Vagrant.plugin("2", :config)
+ attr_accessor :user_home
- def all_enabled_attributes
- all_attributes.collect do |attr|
- instance_variable_get "@#{attr}"
- end.compact
- [@ssh, @vim, @git].compact
- end
+ def git
+ @git ||= CopyMyConf::Git.new
+ end
+
+ def vim
+ @vim ||= CopyMyConf::Vim.new
+ end
- private
- def all_attributes
- self.class.all_attributes
- end
+ def ssh
+ @ssh ||=CopyMyConf::Ssh.new
+ end
- def instance_variable_get_or_set(attr, value)
- instance_variable_get("@#{attr}") || instance_variable_set("@#{attr}", value)
- end
- end
+ def all_enabled_attributes
+ [@ssh, @vim, @git].compact
end
end
end