Sha256: 06c89058cef647e475317efc13ac7fb0ed890e81249e6af74efef54dbf0963c3

Contents?: true

Size: 1.61 KB

Versions: 53

Compression:

Stored size: 1.61 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class Zerigo

      class Record < Fog::Model
        extend Fog::Deprecation
        deprecate :ip, :value
        deprecate :ip=, :value=

        identity :id

        attribute :created_at,  :aliases => 'created-at'
        attribute :value,       :aliases => 'data'
        attribute :domain,      :aliases => 'fqdn'
        attribute :name,        :aliases => 'hostname'
        attribute :description, :aliases => 'notes'
        attribute :priority
        attribute :ttl
        attribute :type,        :aliases => 'host-type'
        attribute :updated_at,  :aliases => 'updated-at'
        attribute :zone_id,     :aliases => 'zone-id'

        def initialize(attributes={})
          super
        end

        def destroy
          requires :identity
          service.delete_host(identity)
          true
        end

        def zone
          @zone
        end

        def save
          requires :zone, :type, :value
          options = {}
          options[:hostname]  = name if name
          options[:notes]     = description if description
          options[:priority]  = priority if priority
          options[:ttl]       = ttl if ttl

          if persisted?
            options[:host_type] = type
            options[:data]      = value
            service.update_host(identity, options)
          else
            data = service.create_host(@zone.id, type, value, options)
            merge_attributes(data.body)
          end

          true
        end

        private

        def zone=(new_zone)
          @zone = new_zone
        end

      end

    end
  end
end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
fog-1.22.0 lib/fog/zerigo/models/dns/record.rb
fog-1.21.0 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/zerigo/models/dns/record.rb
fog-1.20.0 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/zerigo/models/dns/record.rb
fog-1.19.0 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/zerigo/models/dns/record.rb