Class: Rightstuff::Server

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

extract_attributes, load_collection

Constructor Details

#initialize(client, item) ⇒ Server

Returns a new instance of Server.



73
74
75
76
77
# File 'lib/rightstuff.rb', line 73

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



83
84
85
86
87
88
89
# File 'lib/rightstuff.rb', line 83

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

Class Method Details

.collection_xpathObject



79
80
81
# File 'lib/rightstuff.rb', line 79

def self.collection_xpath
  '/servers/server'
end

Instance Method Details

#idObject



91
92
93
# File 'lib/rightstuff.rb', line 91

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

#inputsObject



95
96
97
98
99
# File 'lib/rightstuff.rb', line 95

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

#settingsObject



101
102
103
104
105
106
107
# File 'lib/rightstuff.rb', line 101

def settings
  return @settings if @settings
  doc      = @client.get_rest( 'servers/' + id + '/settings' )
  xml      = Nokogiri::XML( doc )
  @settings = Base.extract_attributes( xml.children )
  @attributes.merge!( settings )
end