Class: Vagrant::Vagrantfile::ConfigFetcher

Inherits:
BasicObject
Defined in:
lib/vagrant/vagrantfile/remote.rb

Instance Method Summary collapse

Constructor Details

#initialize(namespace, client:) ⇒ ConfigFetcher

Returns a new instance of ConfigFetcher.



63
64
65
66
67
# File 'lib/vagrant/vagrantfile/remote.rb', line 63

def initialize(namespace, client:)
  @namespace = namespace
  @client = client
  @logger = ::Log4r::Logger.new("vagrant::vagrantfile::remote::configfetcher")
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, **opts, &block) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/vagrant/vagrantfile/remote.rb', line 69

def method_missing(*args, **opts, &block)
  begin
    return @client.get_value(@namespace, args.last) if
      (args.size == 2 && args.first.to_sym == :[]) ||
      args.size == 1
  rescue => err
    @logger.trace("failed to get config value from remote, calling direct (#{err})")
    return @client.get_config(@namespace).send(*args, **opts, &block)
  end

  @client.get_config(@namespace).send(*args, **opts, &block)
end