diff --git a/plugins/commands/serve/mappers.rb b/plugins/commands/serve/mappers.rb index 9cc3679fb..7083f665a 100644 --- a/plugins/commands/serve/mappers.rb +++ b/plugins/commands/serve/mappers.rb @@ -168,10 +168,28 @@ module VagrantPlugins # @param name [String] # @return [Class] def find_type(name) + parent_module_options = [] name.to_s.split(".").inject(Object) { |memo, n| c = memo.constants.detect { |mc| mc.to_s.downcase == n.to_s.downcase } + if c.nil? + parent_module_options.delete(memo) + parent_module_options.each do |pm| + c = pm.constants.detect { |mc| mc.to_s.downcase == n.to_s.downcase } + if !c.nil? + memo = pm + break + end + end + end + raise NameError, "Failed to find constant for `#{name}'" if c.nil? + + parent_module_options = memo.constants.select { + |mc| mc.to_s.downcase == n.to_s.downcase + }.map { + |mc| memo.const_get(mc) + } memo.const_get(c) } end diff --git a/plugins/commands/serve/util.rb b/plugins/commands/serve/util.rb index d94b13f09..a8f963df7 100644 --- a/plugins/commands/serve/util.rb +++ b/plugins/commands/serve/util.rb @@ -4,6 +4,7 @@ module VagrantPlugins autoload :Cacher, Vagrant.source_root.join("plugins/commands/serve/util/cacher").to_s autoload :ClientSetup, Vagrant.source_root.join("plugins/commands/serve/util/client_setup").to_s autoload :Connector, Vagrant.source_root.join("plugins/commands/serve/util/connector").to_s + autoload :DirectConversion, Vagrant.source_root.join("plugins/commands/serve/util/direct_conversions").to_s autoload :ExceptionTransformer, Vagrant.source_root.join("plugins/commands/serve/util/exception_transformer").to_s autoload :FuncSpec, Vagrant.source_root.join("plugins/commands/serve/util/func_spec").to_s autoload :HasBroker, Vagrant.source_root.join("plugins/commands/serve/util/has_broker").to_s diff --git a/plugins/commands/serve/util/direct_conversions.rb b/plugins/commands/serve/util/direct_conversions.rb index ff4861b24..d13c9a44f 100644 --- a/plugins/commands/serve/util/direct_conversions.rb +++ b/plugins/commands/serve/util/direct_conversions.rb @@ -271,10 +271,28 @@ module Google::Protobuf::MessageExts # @param name [String] # @return [Class] def _vagrant_find_type(name) + parent_module_options = [] name.to_s.split(".").inject(Object) { |memo, n| c = memo.constants.detect { |mc| mc.to_s.downcase == n.to_s.downcase } + if c.nil? + parent_module_options.delete(memo) + parent_module_options.each do |pm| + c = pm.constants.detect { |mc| mc.to_s.downcase == n.to_s.downcase } + if !c.nil? + memo = pm + break + end + end + end + raise NameError, "Failed to find constant for `#{name}'" if c.nil? + + parent_module_options = memo.constants.select { + |mc| mc.to_s.downcase == n.to_s.downcase + }.map { + |mc| memo.const_get(mc) + } memo.const_get(c) } end