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
Sergio Rubio 9dd24ab2bd [dreamhost|dns] Emulate zone model and collection, added tests
Dreamhost API has no concept of Zone, but we can emulate it.
2013-01-21 23:26:30 +01:00

38 lines
837 B
Ruby

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] }
else
data = service.list_records.body['data']
end
load(data)
end
def get(record_name)
data = service.list_records.body['data'].find { |r| r['record'] == record_name }
new(data)
rescue Excon::Errors::NotFound
nil
end
end
def new(attributes = {})
requires :zone
super({ :zone => zone }.merge!(attributes))
end
end
end
end