Class: Fog::Compute::AWS::Address
- Defined in:
- lib/fog/aws/models/compute/address.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(attributes = {}) ⇒ Address
constructor
A new instance of Address.
- #save ⇒ Object
- #server ⇒ Object
- #server=(new_server) ⇒ Object
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Address
Returns a new instance of Address.
17 18 19 20 21 |
# File 'lib/fog/aws/models/compute/address.rb', line 17 def initialize(attributes = {}) # assign server first to prevent race condition with persisted? self.server = attributes.delete(:server) super end |
Instance Method Details
#destroy ⇒ Object
23 24 25 26 27 28 |
# File 'lib/fog/aws/models/compute/address.rb', line 23 def destroy requires :public_ip service.release_address(allocation_id || public_ip) true end |
#save ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/aws/models/compute/address.rb', line 42 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? data = service.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
38 39 40 |
# File 'lib/fog/aws/models/compute/address.rb', line 38 def server service.servers.get(server_id) end |
#server=(new_server) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/fog/aws/models/compute/address.rb', line 30 def server=(new_server) if new_server associate(new_server) else disassociate end end |