Class: Fog::AWS::EC2::Volumes

Inherits:
Collection show all
Defined in:
lib/fog/aws/models/ec2/volumes.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes) ⇒ Volumes

Returns a new instance of Volumes.



23
24
25
26
# File 'lib/fog/aws/models/ec2/volumes.rb', line 23

def initialize(attributes)
  @volume_id ||= []
  super
end

Instance Method Details

#all(volume_id = @volume_id) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/fog/aws/models/ec2/volumes.rb', line 28

def all(volume_id = @volume_id)
  @volume_id = volume_id
  data = connection.describe_volumes(volume_id).body
  load(data['volumeSet'])
  if server
    self.replace(self.select {|volume| volume.server_id == server.id})
  end
  self
end

#get(volume_id) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/fog/aws/models/ec2/volumes.rb', line 38

def get(volume_id)
  if volume_id
    all(volume_id).first
  end
rescue Fog::Errors::NotFound
  nil
end

#new(attributes = {}) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/fog/aws/models/ec2/volumes.rb', line 46

def new(attributes = {})
  if server
    super({ :server => server }.merge!(attributes))
  else
    super
  end
end