Fix Type::Booleans leaking through capabilities
We had some cases where calling a capability that returned a boolean was not getting correctly unpacked, so instead of `true` or `false` the capability was putting out `VagrantPlugins::CommandServe::Type::Boolean`. This may have been happening in _all_ cases where a boolean was returned from a capability and we just didn't notice it yet because the return value was always truthy. These tweaks should help ensure that Ruby types make it out where they are supposed to be in Args::Direct usage.
This commit is contained in:
parent
186824a568
commit
75d900c93b
@ -35,15 +35,15 @@ module VagrantPlugins
|
||||
name: cap_name,
|
||||
)
|
||||
)
|
||||
cb = proc do |name, args|
|
||||
cb = lambda do |name, args|
|
||||
result = client.capability(
|
||||
SDK::Platform::Capability::NamedRequest.new(
|
||||
name: name,
|
||||
func_args: args,
|
||||
)
|
||||
)
|
||||
return nil if result.nil?
|
||||
mapper.map(result.result)
|
||||
return nil if result.nil? || result.result.nil?
|
||||
mapper.map(SDK::Args::Direct.new(arguments: [result.result])).arguments.first
|
||||
end
|
||||
[spec, cb]
|
||||
end
|
||||
|
||||
@ -373,7 +373,10 @@ end
|
||||
class Hashicorp::Vagrant::Sdk::Args::Direct
|
||||
def to_ruby
|
||||
VagrantPlugins::CommandServe::Type::Direct.new(
|
||||
arguments: arguments.map(&:to_ruby)
|
||||
arguments: arguments.map { |arg|
|
||||
val = arg.to_ruby
|
||||
val.is_a?(VagrantPlugins::CommandServe::Type) ? val.value : val
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user