Class: VagrantPlugins::Skytap::API::Resource

Inherits:
Object
  • Object
show all
Includes:
SpecifiedAttributes
Defined in:
lib/vagrant-skytap/api/resource.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SpecifiedAttributes

#get_api_attribute, included

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

#attrsObject (readonly)

Returns the value of attribute attrs.



9
10
11
# File 'lib/vagrant-skytap/api/resource.rb', line 9

def attrs
  @attrs
end

#envObject (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_nameObject



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

#reloadObject



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

#urlObject



22
23
24
# File 'lib/vagrant-skytap/api/resource.rb', line 22

def url
  "/#{self.class.resource_name.downcase}s/#{id}"
end