Class: Warg::Config
- Inherits:
-
Object
- Object
- Warg::Config
- Defined in:
- lib/warg.rb
Direct Known Subclasses
Defined Under Namespace
Classes: VariableSet
Instance Attribute Summary collapse
-
#default_user ⇒ Object
Returns the value of attribute default_user.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#variables_sets ⇒ Object
readonly
Returns the value of attribute variables_sets.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #variables(name, &block) ⇒ Object
- #variables_set_defined?(name) ⇒ Boolean
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
1222 1223 1224 1225 |
# File 'lib/warg.rb', line 1222 def initialize @hosts = HostCollection.new @variables_sets = Set.new end |
Instance Attribute Details
#default_user ⇒ Object
Returns the value of attribute default_user.
1218 1219 1220 |
# File 'lib/warg.rb', line 1218 def default_user @default_user end |
#hosts ⇒ Object
Returns the value of attribute hosts.
1219 1220 1221 |
# File 'lib/warg.rb', line 1219 def hosts @hosts end |
#variables_sets ⇒ Object (readonly)
Returns the value of attribute variables_sets.
1220 1221 1222 |
# File 'lib/warg.rb', line 1220 def variables_sets @variables_sets end |
Instance Method Details
#[](name) ⇒ Object
1235 1236 1237 1238 1239 |
# File 'lib/warg.rb', line 1235 def [](name) if variables_set_defined?(name.to_s) instance_variable_get("@#{name}") end end |
#variables(name, &block) ⇒ Object
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 |
# File 'lib/warg.rb', line 1241 def variables(name, &block) variables_name = name.to_s ivar_name = "@#{variables_name}" if @variables_sets.include?(variables_name) variables_object = instance_variable_get(ivar_name) else @variables_sets << variables_name singleton_class.send(:attr_reader, variables_name) variables_object = instance_variable_set(ivar_name, VariableSet.new(variables_name, self)) end block.call(variables_object) end |
#variables_set_defined?(name) ⇒ Boolean
1231 1232 1233 |
# File 'lib/warg.rb', line 1231 def variables_set_defined?(name) @variables_sets.include?(name.to_s) end |