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/zerigo/models/dns/records.rb
2010-12-22 20:36:53 -08:00

41 lines
831 B
Ruby

require 'fog/core/collection'
require 'fog/zerigo/models/dns/record'
module Fog
module Zerigo
class DNS
class Records < Fog::Collection
attribute :zone
model Fog::Zerigo::DNS::Record
def all
requires :zone
parent = zone.collection.get(zone.identity)
if parent
merge_attributes(parent.records.attributes)
load(parent.records.map {|record| record.attributes})
else
nil
end
end
def get(record_id)
data = connection.get_host(record_id).body
new(data)
rescue Excon::Errors::NotFound
nil
end
def new(attributes = {})
requires :zone
super({ :zone => zone }.merge!(attributes))
end
end
end
end
end