class HashiCorp::VagrantVMwareDesktop::Helper::VagrantUtility::Response

Response wrapper class

Attributes

value[R]

Raw value being wrapped

@return [Hash]

Public Class Methods

new(value) click to toggle source
# File lib/vagrant-vmware-desktop/helper/vagrant_utility.rb, line 23
def initialize(value)
  if !value.is_a?(Hash)
    raise TypeError.new("Expecting value of `Hash` type but received `#{value.class}`")
  end
  @value = value
end

Public Instance Methods

[](v) click to toggle source
# File lib/vagrant-vmware-desktop/helper/vagrant_utility.rb, line 43
def [](v)
  value[v]
end
get(*args) click to toggle source

Provides Hash#dig functionality but will raise an invalid response exception if given path raises an error.

@return [Object]

# File lib/vagrant-vmware-desktop/helper/vagrant_utility.rb, line 35
def get(*args)
  begin
    value.dig(*args)
  rescue => err
    raise Errors::DriverAPIInvalidResponse
  end
end
success?() click to toggle source

@return [TrueClass, FalseClass] response is success

# File lib/vagrant-vmware-desktop/helper/vagrant_utility.rb, line 48
def success?
  value[:success]
end