class Vagrant::Config::V2::DummyConfig
This is a configuration object that can have anything done to it. Anything, and it just appears to keep working.
Constants
- LOG
Public Instance Methods
instance_variables_hash()
click to toggle source
# File lib/vagrant/config/v2/dummy_config.rb, line 48 def instance_variables_hash instance_variables.inject({}) do |acc, iv| acc[iv.to_s[1..-1]] = instance_variable_get(iv) acc end end
merge(c)
click to toggle source
# File lib/vagrant/config/v2/dummy_config.rb, line 35 def merge(c) c end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
Vagrant::Plugin::V2::Config#method_missing
# File lib/vagrant/config/v2/dummy_config.rb, line 9 def method_missing(name, *args, &block) # There are a few scenarios where ruby will attempt to implicity # coerce a given object into a certain type. DummyConfigs can end up # in some of these scenarios when they're being shipped around in # callbacks with splats. If method_missing allows these methods to be # called but continues to return DummyConfig back, Ruby will raise a # TypeError. Doing the normal thing of raising NoMethodError allows # DummyConfig to behave normally as its being passed through splats. # # For a bit more detail and some keywords for further searching, see: # https://ruby-doc.org/core-2.7.2/doc/implicit_conversion_rdoc.html if [:to_hash, :to_ary].include?(name) return super end # Trying to define a variable if name.to_s.match(/^[\w]*=/) LOG.debug("found name #{name}") LOG.debug("setting instance variable name #{name.to_s.split("=")[0]}") var_name = "@#{name.to_s.split("=")[0]}" self.instance_variable_set(var_name, args[0]) else DummyConfig.new end end
set_options(options)
click to toggle source
# File lib/vagrant/config/v2/dummy_config.rb, line 39 def set_options(options) options.each do |key, value| if key.to_s.match(/^[\w]*=/) var_name = "@#{key.to_s}" self.instance_variable_set(var_name, value) end end end