Sha256: dd4ac5f32e681378945a994a11baa31c718bcfbd732ec783779e2b17dcdb9b3b

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

module Fog
  module AWS
    class EC2

      class Address < Fog::Model

        attribute :instance_id, 'instanceId'
        attribute :public_ip,   'publicIp'

        def addresses
          @addresses
        end

        def initialize(new_attributes = {})
          new_attributes = {
            :instance_id => ''
          }.merge!(new_attributes)
          super(new_attributes)
        end

        def destroy
          connection.release_address(@public_ip)
          true
        end

        def instance=(new_instance)
          @instance_id = new_instance.instance_id
          connection.associate_address(@instance_id, @public_ip)
        end

        def reload
          new_attributes = addresses.get(@public_ip).attributes
          merge_attributes(new_attributes)
        end

        def save
          data = connection.allocate_address
          @public_ip = data.body['publicIp']
          true
        end

        private

        def addresses=(new_addresses)
          @addresses = new_addresses
        end

      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fog-0.0.22 lib/fog/aws/models/ec2/address.rb
fog-0.0.21 lib/fog/aws/models/ec2/address.rb
fog-0.0.20 lib/fog/aws/models/ec2/address.rb
fog-0.0.19 lib/fog/aws/models/ec2/address.rb
fog-0.0.18 lib/fog/aws/models/ec2/address.rb
fog-0.0.17 lib/fog/aws/models/ec2/address.rb
fog-0.0.16 lib/fog/aws/models/ec2/address.rb
fog-0.0.15 lib/fog/aws/models/ec2/address.rb
fog-0.0.14 lib/fog/aws/models/ec2/address.rb