Class: VagrantPlugins::Registration::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-registration/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region_specific = false) ⇒ Config

Returns a new instance of Config.



9
10
11
12
# File 'lib/vagrant-registration/config.rb', line 9

def initialize(region_specific=false)
  @conf = UNSET_VALUE
  @logger = Log4r::Logger.new('vagrant_registration::config')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



22
23
24
25
26
27
# 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

Instance Attribute Details

#confObject (readonly)

Returns the value of attribute conf.



7
8
9
# File 'lib/vagrant-registration/config.rb', line 7

def conf
  @conf
end

Instance Method Details

#finalize!Object



14
15
16
17
18
19
20
# 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