Class: HashiCorp::VagrantVMwareDesktop::Helper::VagrantUtility::Response
- Inherits:
-
Object
- Object
- HashiCorp::VagrantVMwareDesktop::Helper::VagrantUtility::Response
- Defined in:
- lib/vagrant-vmware-desktop/helper/vagrant_utility.rb
Overview
Response wrapper class
Instance Attribute Summary collapse
-
#value ⇒ Hash
readonly
Raw value being wrapped.
Instance Method Summary collapse
- #[](v) ⇒ Object
-
#get(*args) ⇒ Object
Provides Hash#dig functionality but will raise an invalid response exception if given path raises an error.
-
#initialize(value) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ TrueClass, FalseClass
Response is success.
Constructor Details
#initialize(value) ⇒ Response
Returns a new instance of Response.
26 27 28 29 30 31 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 26 def initialize(value) if !value.is_a?(Hash) raise TypeError.new("Expecting value of `Hash` type but received `#{value.class}`") end @value = value end |
Instance Attribute Details
#value ⇒ Hash (readonly)
Raw value being wrapped
24 25 26 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 24 def value @value end |
Instance Method Details
#[](v) ⇒ Object
46 47 48 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 46 def [](v) value[v] end |
#get(*args) ⇒ Object
Provides Hash#dig functionality but will raise an invalid response exception if given path raises an error.
38 39 40 41 42 43 44 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 38 def get(*args) begin value.dig(*args) rescue => err raise Errors::DriverAPIInvalidResponse end end |
#success? ⇒ TrueClass, FalseClass
Returns response is success.
51 52 53 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 51 def success? value[:success] end |