Class: Rightstuff::ServerArray

Inherits:
Base
  • Object
show all
Defined in:
lib/rightstuff/server_array.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

extract_attributes, load_collection

Constructor Details

#initialize(client, item) ⇒ ServerArray

Returns a new instance of ServerArray.



7
8
9
10
11
# File 'lib/rightstuff/server_array.rb', line 7

def initialize( client, item )
  @inputs    = nil
  @instances = nil
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



17
18
19
20
21
22
# File 'lib/rightstuff/server_array.rb', line 17

def method_missing( name , *args, &block )
  result = super
  return result unless result.nil?
  return nil    if @attributes[ :state ] == 'stopped'
  return @attributes[ name ]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/rightstuff/server_array.rb', line 5

def attributes
  @attributes
end

Class Method Details

.collection_xpathObject



13
14
15
# File 'lib/rightstuff/server_array.rb', line 13

def self.collection_xpath
  '/server-arrays/server-array'
end

Instance Method Details

#idObject



24
25
26
# File 'lib/rightstuff/server_array.rb', line 24

def id
  @attributes[ :href ].split( '/' ).last
end

#inputsObject



28
29
30
31
32
# File 'lib/rightstuff/server_array.rb', line 28

def inputs
  return @inputs if @inputs
  # Add inputs to instance data
  # @client.get( @attributes[ 'href' ] )
end

#instancesObject



34
35
36
37
38
# File 'lib/rightstuff/server_array.rb', line 34

def instances
  return @instances if @instances
  body     = Nokogiri::XML( @client.get_rest( "server_arrays/#{id}/instances" ) )
  @instances = Rightstuff::ArrayInstance.load_collection( @client, body )
end