Class: Shared::Configuration Abstract

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

Overview

This class is abstract.

A configuration file in an instance

Instance Attribute Summary collapse

Attributes inherited from Resource

#location, #security

Instance Method Summary collapse

Constructor Details

#initialize(location, client, instance_type, instance_class) ⇒ Configuration

Returns a new instance of Configuration.



35
36
37
38
39
40
41
42
43
44
# File 'lib/vas/shared/configuration.rb', line 35

def initialize(location, client, instance_type, instance_class)
  super(location, client)

  @instance_class = instance_class

  @instance_location = Util::LinkUtils.get_link_href(details, instance_type)
  @content_location = Util::LinkUtils.get_link_href(details, 'content')

  @path = details['path']
end

Instance Attribute Details

#pathString (readonly)

Returns the configuration’s path.

Returns:

  • (String)

    the configuration’s path



23
24
25
# File 'lib/vas/shared/configuration.rb', line 23

def path
  @path
end

#sizeInteger (readonly)

Returns the configuration’s size.

Returns:

  • (Integer)

    the configuration’s size



26
27
28
# File 'lib/vas/shared/configuration.rb', line 26

def size
  @size
end

Instance Method Details

#content {|chunk| ... } ⇒ void

This method returns an undefined value.

Retrieves the configuration’s content from the server and passes it to the block

Yields:

  • (chunk)

    a chunk of the configuration’s content



59
60
61
# File 'lib/vas/shared/configuration.rb', line 59

def content(&block)
  client.get_stream(@content_location, &block)
end

#instanceInstance

Returns the instance that owns the configuration.

Returns:

  • (Instance)

    the instance that owns the configuration



64
65
66
# File 'lib/vas/shared/configuration.rb', line 64

def instance
  @instance ||= @instance_class.new(@instance_location, client)
end

#reloadvoid

This method returns an undefined value.

Reloads the configuration’s details from the server



49
50
51
52
# File 'lib/vas/shared/configuration.rb', line 49

def reload
  super
  @size = details['size']
end

#to_sString

Returns a string representation of the configuration.

Returns:

  • (String)

    a string representation of the configuration



69
70
71
# File 'lib/vas/shared/configuration.rb', line 69

def to_s
  "#<#{self.class} name='#@path' size='#@size'>"
end