1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/dns/models/dnsimple/record.rb
2011-02-24 17:14:50 -08:00

55 lines
1.1 KiB
Ruby

require 'fog/core/model'
module Fog
module DNSimple
class DNS
class Record < Fog::Model
identity :id
attribute :name
attribute :ip, :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={})
self.ttl ||= 3600
super
end
def destroy
requires :identity
connection.delete_record(identity)
true
end
def zone
@zone
end
def save
requires :name, :type, :ip
options = {}
options[:prio] = priority if priority
options[:ttl] = ttl if ttl
connection.create_record(zone.id, name, type, ip, options)
merge_attributes(data.body)
true
end
private
def zone=(new_zone)
@zone = new_zone
end
end
end
end
end