class Warg::Config

Attributes

default_user[RW]
hosts[R]
variables_sets[R]

Public Class Methods

new() click to toggle source
# File lib/warg.rb, line 1249
def initialize
  @hosts = HostCollection.new
  @variables_sets = Set.new
end

Public Instance Methods

[](name) click to toggle source
# File lib/warg.rb, line 1262
def [](name)
  if variables_set_defined?(name.to_s)
    instance_variable_get("@#{name}")
  end
end
hosts=(value) click to toggle source
# File lib/warg.rb, line 1254
def hosts=(value)
  @hosts = HostCollection.from(value)
end
variables(name, &block) click to toggle source
# File lib/warg.rb, line 1268
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) click to toggle source
# File lib/warg.rb, line 1258
def variables_set_defined?(name)
  @variables_sets.include?(name.to_s)
end