Class: Shared::StateResource Abstract

Inherits:
Resource show all
Defined in:
lib/vas/shared/state_resource.rb

Overview

This class is abstract.

A resource that has state, i.e. it can be started and stopped and its state can be queried

Instance Attribute Summary

Attributes inherited from Resource

#location, #security

Instance Method Summary collapse

Constructor Details

#initialize(location, client) ⇒ StateResource

Returns a new instance of StateResource.



24
25
26
27
# File 'lib/vas/shared/state_resource.rb', line 24

def initialize(location, client)
  super(location, client)
  @state_location = Util::LinkUtils.get_link_href(details, 'state')
end

Instance Method Details

#startvoid

This method returns an undefined value.

Starts the resource



32
33
34
# File 'lib/vas/shared/state_resource.rb', line 32

def start
  client.post(@state_location, { :status => 'STARTED' })
end

#stateString

Returns Retrieves the state of the resource from the server.

Returns:

  • (String)

    Retrieves the state of the resource from the server



44
45
46
# File 'lib/vas/shared/state_resource.rb', line 44

def state
  client.get(@state_location)['status']
end

#stopvoid

This method returns an undefined value.

Stops the resource



39
40
41
# File 'lib/vas/shared/state_resource.rb', line 39

def stop
  client.post(@state_location, { :status => 'STOPPED' })
end