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.
1302 1303 1304 1305 |
# File 'lib/warg.rb', line 1302 def initialize @hosts = HostCollection.new @variables_sets = Set.new end |
Instance Attribute Details
#default_user ⇒ Object
Returns the value of attribute default_user.
1298 1299 1300 |
# File 'lib/warg.rb', line 1298 def default_user @default_user end |
#hosts ⇒ Object
Returns the value of attribute hosts.
1299 1300 1301 |
# File 'lib/warg.rb', line 1299 def hosts @hosts end |
#variables_sets ⇒ Object (readonly)
Returns the value of attribute variables_sets.
1300 1301 1302 |
# File 'lib/warg.rb', line 1300 def variables_sets @variables_sets end |
Instance Method Details
#[](name) ⇒ Object
1315 1316 1317 1318 1319 |
# File 'lib/warg.rb', line 1315 def [](name) if variables_set_defined?(name.to_s) instance_variable_get("@#{name}") end end |
#variables(name, &block) ⇒ Object
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 |
# File 'lib/warg.rb', line 1321 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
1311 1312 1313 |
# File 'lib/warg.rb', line 1311 def variables_set_defined?(name) @variables_sets.include?(name.to_s) end |