Class: VagrantPlugins::Skytap::API::Resource
- Includes:
- SpecifiedAttributes
- Defined in:
- lib/vagrant-skytap/api/resource.rb
Direct Known Subclasses
Credentials, Environment, Interface, Network, PublicIp, PublishedService, Vm, Vpn, VpnAttachment
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Resource
constructor
A new instance of Resource.
- #refresh(attrs) ⇒ Object
- #reload ⇒ Object
- #url ⇒ Object
Methods included from SpecifiedAttributes
Constructor Details
#initialize(*args) ⇒ Resource
Returns a new instance of Resource.
17 18 19 20 |
# File 'lib/vagrant-skytap/api/resource.rb', line 17 def initialize(*args) @attrs = args.first @env = args.last end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
9 10 11 |
# File 'lib/vagrant-skytap/api/resource.rb', line 9 def attrs @attrs end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/vagrant-skytap/api/resource.rb', line 9 def env @env end |
Class Method Details
.resource_name ⇒ Object
12 13 14 |
# File 'lib/vagrant-skytap/api/resource.rb', line 12 def resource_name name.split("::").last end |
Instance Method Details
#refresh(attrs) ⇒ Object
31 32 33 34 |
# File 'lib/vagrant-skytap/api/resource.rb', line 31 def refresh(attrs) @attrs = attrs self end |
#reload ⇒ Object
26 27 28 29 |
# File 'lib/vagrant-skytap/api/resource.rb', line 26 def reload resp = api_client.get(url) refresh(JSON.load(resp.body)) end |
#url ⇒ Object
22 23 24 |
# File 'lib/vagrant-skytap/api/resource.rb', line 22 def url "/#{self.class.resource_name.downcase}s/#{id}" end |