Check super method to be called and force no arguments if none expected

This fixes an issue with Ruby 2.6 where `super` usage when no
    arguments are passed results in an argument error
This commit is contained in:
Chris Roberts 2021-10-01 11:07:36 -07:00 committed by Paul Hinze
parent e89d344770
commit 0401f9cad4
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
3 changed files with 18 additions and 3 deletions

View File

@ -12,7 +12,12 @@ module VagrantPlugins
@broker = opts.delete(:broker)
raise ArgumentError,
"Expected `Broker' to be provided" if @broker.nil?
super
if self.method(:initialize).super_method.parameters.empty?
super()
else
super
end
end
end
end

View File

@ -10,7 +10,12 @@ module VagrantPlugins
def initialize(*args, **opts, &block)
@logger = Log4r::Logger.new(self.class.name.downcase)
super
if self.method(:initialize).super_method.parameters.empty?
super()
else
super
end
end
end
end

View File

@ -14,7 +14,12 @@ module VagrantPlugins
if respond_to?(:broker)
@mapper.add_argument(broker)
end
super
if self.method(:initialize).super_method.parameters.empty?
super()
else
super
end
end
end
end