Sha256: 6a546639726a53a8d6c6f6b71d165b718d9c3abaa7cae6cb408f05a50f30c7f9

Contents?: true

Size: 1.44 KB

Versions: 17

Compression:

Stored size: 1.44 KB

Contents

require 'fog/core/model'

module Fog
  module Slicehost
    class DNS

      class Record < Fog::Model

        identity :id

        attribute :active
        attribute :ip,          :aliases => 'ip'
        attribute :name
        attribute :description, :aliases => 'aux'
        attribute :ttl
        attribute :type,        :aliases => 'record_type'
        attribute :zone_id

        def initialize(attributes={})
          self.active ||= true
          self.ttl    ||= 3600
          super
        end

        def active=(new_active)
          attributes[:active] = case new_active
          when false, 'N'
            false
          when true, 'Y'
            true
          end
        end

        def destroy
          requires :identity
          connection.delete_record(identity)
          true
        end

        def zone
          @zone
        end

        def save
          raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
          requires :ip, :name, :type, :zone
          options = {}
          options[:active]  = active ? 'Y' : 'N'
          options[:aux]     = description if description
          options[:ttl]     = ttl if ttl
          data = connection.create_record(type, zone.id, name, ip, options)
          merge_attributes(data.body)
          true
        end

        private
        
        def zone=(new_zone)
          @zone = new_zone
        end

      end

    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
fog-0.8.2 lib/fog/dns/models/slicehost/record.rb
fog-0.8.1 lib/fog/dns/models/slicehost/record.rb
fog-0.8.0 lib/fog/dns/models/slicehost/record.rb
fog-0.7.2 lib/fog/dns/models/slicehost/record.rb
fog-0.7.1 lib/fog/dns/models/slicehost/record.rb
fog-0.7.0 lib/fog/dns/models/slicehost/record.rb
fog-0.6.0 lib/fog/dns/models/slicehost/record.rb
fog-0.5.3 lib/fog/dns/models/slicehost/record.rb
fog-0.5.2 lib/fog/dns/models/slicehost/record.rb
fog-0.5.1 lib/fog/dns/models/slicehost/record.rb
fog-0.5.0 lib/fog/dns/models/slicehost/record.rb
phpfog-fog-0.4.1.3 lib/fog/dns/models/slicehost/record.rb
phpfog-fog-0.4.1.2 lib/fog/dns/models/slicehost/record.rb
phpfog-fog-0.4.1.1 lib/fog/dns/models/slicehost/record.rb
phpfog-fog-0.4.1 lib/fog/dns/models/slicehost/record.rb
fog-0.4.1 lib/fog/dns/models/slicehost/record.rb
fog-0.4.0 lib/fog/slicehost/models/dns/record.rb