Sha256: 0923a1bef10fc695077faa68941a0c27d8563bee2ed4c50c31477e810925c4a2

Contents?: true

Size: 1.47 KB

Versions: 39

Compression:

Stored size: 1.47 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class DNSimple

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

        identity :id

        attribute :name
        attribute :value,       :aliases => "content"
        attribute :ttl
        attribute :created_at
        attribute :updated_at
        attribute :zone_id,     :aliases => "domain_id"
        attribute :type,        :aliases => "record_type"
        attribute :priority,    :aliases => "prio"

        def initialize(attributes={})
          super
        end

        def destroy
          service.delete_record(zone.id, identity)
          true
        end

        def zone
          @zone
        end

        def save
          requires :name, :type, :value
          options = {}
          options[:prio] = priority if priority
          options[:ttl]  = ttl if ttl

          # decide whether its a new record or update of an existing
          if id.nil?
            data = service.create_record(zone.id, name, type, value, options)
          else
            options[:name] = name if name
            options[:content] = value if value
            options[:type] = type if type
            data = service.update_record(zone.id, id, options)
          end

          merge_attributes(data.body["record"])
          true
        end

        private

        def zone=(new_zone)
          @zone = new_zone
        end

      end

    end
  end
end

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
fog-maestrodev-1.19.0.20140212012611 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/dnsimple/models/dns/record.rb
fog-1.19.0 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/dnsimple/models/dns/record.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/dnsimple/models/dns/record.rb