projects
/
vagrant-dotfiles.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Provisioner objects created by config
[vagrant-dotfiles.git]
/
lib
/
copy_my_conf
/
config.rb
diff --git
a/lib/copy_my_conf/config.rb
b/lib/copy_my_conf/config.rb
index
b077607
..
23f150e
100644
(file)
--- a/
lib/copy_my_conf/config.rb
+++ b/
lib/copy_my_conf/config.rb
@@
-5,13
+5,28
@@
module Vagrant
def self.all_attributes
[:ssh, :vim, :git]
end
def self.all_attributes
[:ssh, :vim, :git]
end
- attr_accessor *all_attributes
attr_accessor :user_home
attr_accessor :user_home
- def all_true
- self.class.all_attributes.collect do |attr|
- self.send(attr) ? attr : nil
+ all_attributes.each do |attr|
+ define_method(attr) do
+ instance_variable_get_or_set(attr, CopyMyConf.const_get("#{attr.capitalize}").new)
+ end
+ end
+
+ def all_enabled_attributes
+ all_attributes.collect do |attr|
+ instance_variable_get "@#{attr}"
end.compact
end.compact
+ [@ssh, @vim, @git].compact
+ end
+
+ private
+ def all_attributes
+ self.class.all_attributes
+ end
+
+ def instance_variable_get_or_set(attr, value)
+ instance_variable_get("@#{attr}") || instance_variable_set("@#{attr}", value)
end
end
end
end
end
end