Class: Fog::Compute::AWS::Address
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::AWS::Address
show all
- Defined in:
- lib/fog/aws/models/compute/address.rb
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Address
16
17
18
19
20
|
# File 'lib/fog/aws/models/compute/address.rb', line 16
def initialize(attributes = {})
self.server = attributes.delete(:server)
super
end
|
Instance Method Details
#destroy ⇒ Object
22
23
24
25
26
27
|
# File 'lib/fog/aws/models/compute/address.rb', line 22
def destroy
requires :public_ip
connection.release_address(allocation_id || public_ip)
true
end
|
#save ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/fog/aws/models/compute/address.rb', line 41
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
data = connection.allocate_address(domain).body
new_attributes = data.reject {|key,value| key == 'requestId'}
merge_attributes(new_attributes)
if @server
self.server = @server
end
true
end
|
#server ⇒ Object
37
38
39
|
# File 'lib/fog/aws/models/compute/address.rb', line 37
def server
connection.servers.get(server_id)
end
|
#server=(new_server) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/fog/aws/models/compute/address.rb', line 29
def server=(new_server)
if new_server
associate(new_server)
else
disassociate
end
end
|