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/dreamhost/models/dns/records.rb

39 lines
837 B
Ruby
Raw Normal View History

2012-03-10 17:02:28 -05:00
require 'fog/core/collection'
require 'fog/dreamhost/models/dns/record'
module Fog
module DNS
class Dreamhost
class Records < Fog::Collection
model Fog::DNS::Dreamhost::Record
def all(filter = {})
clear
if filter[:zone]
data = service.list_records.body['data'].find_all { |r| r['zone'] == filter[:zone] }
2012-03-10 17:02:28 -05:00
else
data = service.list_records.body['data']
2012-03-10 17:02:28 -05:00
end
load(data)
end
def get(record_name)
data = service.list_records.body['data'].find { |r| r['record'] == record_name }
2012-03-10 17:02:28 -05:00
new(data)
rescue Excon::Errors::NotFound
nil
end
end
def new(attributes = {})
requires :zone
super({ :zone => zone }.merge!(attributes))
end
2012-03-10 17:02:28 -05:00
end
end
end