Remove with_info method which is isolated to the module

This commit is contained in:
Chris Roberts 2021-12-17 14:59:21 -08:00 committed by Paul Hinze
parent de18081a35
commit 0bb424c2df
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -1,3 +1,5 @@
require "ostruct"
module VagrantPlugins
module CommandServe
module Service
@ -10,13 +12,12 @@ module VagrantPlugins
autoload :ProviderService, Vagrant.source_root.join("plugins/commands/serve/service/provider_service").to_s
autoload :SyncedFolderService, Vagrant.source_root.join("plugins/commands/serve/service/synced_folder_service").to_s
class ServiceInfo < OpenStruct
class ServiceInfo
# @return [String] Name of requested plugin
attr_reader :plugin_name
def initialize(plugin_name: nil)
@plugin_name = plugin_name
def initialize(plugin_name: nil, broker: nil)
super()
self.plugin_name = plugin_name.to_sym if plugin_name
self.broker = broker
end
def self.info
@ -28,15 +29,8 @@ module VagrantPlugins
info
end
def self.with_info(context)
info = new(plugin_name: context.metadata["plugin_name"])
Thread.current.thread_variable_set(:service_info, info)
return if !block_given?
begin
yield info
ensure
Thread.current.thread_variable_set(:service_info, nil)
end
def self.with_info(context, broker: nil)
raise NotImplementedError
end
end
end