class VagrantPlugins::Registration::Config

Attributes

Public Class Methods

Source
# File lib/vagrant-registration/config.rb, line 9
def initialize(region_specific=false)
  @conf = UNSET_VALUE
  @logger = Log4r::Logger.new('vagrant_registration::config')
end

Public Instance Methods

Source
# File lib/vagrant-registration/config.rb, line 14
def finalize!
  get_config
  @conf.skip = false unless @conf.skip
  # Unregister on halt by default
  @conf.unregister_on_halt = true if @conf.unregister_on_halt.nil?
  @logger.info I18n.t('registration.config.final_message', conf: @conf.inspect)
end
Source
# File lib/vagrant-registration/config.rb, line 22
def method_missing(method_sym, *arguments, &block)
  get_config
  command = "@conf.#{method_sym} #{adjust_arguments(arguments)}"
  @logger.info I18n.t('registration.config.method_missing_command', command: command)
  eval command
end

Private Instance Methods

Source
# File lib/vagrant-registration/config.rb, line 39
def adjust_arguments(args)
  return '' if args.size < 1
  args.inspect[1..-2]
end

Serialize strings, nil and boolean values, symbols, arrays and hashes to be used within eval()

Source
# File lib/vagrant-registration/config.rb, line 33
def get_config
  @conf = OpenStruct.new if @conf == UNSET_VALUE
end

Don’t set @conf to OpenStruct in initialize to preserve config hierarchy