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.
23 24 25 26 27 28 |
# 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 |
Instance Attribute Details
#value ⇒ Hash (readonly)
Raw value being wrapped
21 22 23 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 21 def value @value end |
Instance Method Details
#[](v) ⇒ Object
43 44 45 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 43 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.
35 36 37 38 39 40 41 |
# 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? ⇒ TrueClass, FalseClass
Returns response is success.
48 49 50 |
# File 'lib/vagrant-vmware-desktop/helper/vagrant_utility.rb', line 48 def success? value[:success] end |