Class: Fog::Compute::HP::Address
- Defined in:
- lib/rackspace-fog/hp/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=(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 Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Address
Returns a new instance of Address.
15 16 17 18 19 |
# File 'lib/rackspace-fog/hp/models/compute/address.rb', line 15 def initialize(attributes = {}) # assign server first to prevent race condition with new_record? self.server = attributes.delete(:server) super end |
Instance Method Details
#destroy ⇒ Object
21 22 23 24 25 26 |
# File 'lib/rackspace-fog/hp/models/compute/address.rb', line 21 def destroy requires :id connection.release_address(id) true end |
#save ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rackspace-fog/hp/models/compute/address.rb', line 36 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity data = connection.allocate_address.body['floating_ip'] new_attributes = data.reject {|key,value| !['id', 'instance_id', 'ip', 'fixed_ip'].include?(key)} merge_attributes(new_attributes) if @server self.server = @server end true end |
#server=(new_server) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rackspace-fog/hp/models/compute/address.rb', line 28 def server=(new_server) if new_server associate(new_server) else disassociate end end |