23f150e999dba0b9ef74edf11bdf36d7a7833f0d
[vagrant-dotfiles.git] / lib / copy_my_conf / config.rb
1 module Vagrant
2 module Provisioners
3 class CopyMyConf < Base
4 class Config < Vagrant::Config::Base
5 def self.all_attributes
6 [:ssh, :vim, :git]
7 end
8 attr_accessor :user_home
9
10 all_attributes.each do |attr|
11 define_method(attr) do
12 instance_variable_get_or_set(attr, CopyMyConf.const_get("#{attr.capitalize}").new)
13 end
14 end
15
16 def all_enabled_attributes
17 all_attributes.collect do |attr|
18 instance_variable_get "@#{attr}"
19 end.compact
20 [@ssh, @vim, @git].compact
21 end
22
23 private
24 def all_attributes
25 self.class.all_attributes
26 end
27
28 def instance_variable_get_or_set(attr, value)
29 instance_variable_get("@#{attr}") || instance_variable_set("@#{attr}", value)
30 end
31 end
32 end
33 end
34 end
35