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

39 lines
760 B
Ruby
Raw Normal View History

2011-02-24 20:14:50 -05:00
require 'fog/core/collection'
require 'fog/dnsimple/models/dns/record'
2011-02-24 20:14:50 -05:00
module Fog
module DNS
class DNSimple
2011-02-24 20:14:50 -05:00
class Records < Fog::Collection
attribute :zone
model Fog::DNS::DNSimple::Record
2011-02-24 20:14:50 -05:00
def all
requires :zone
clear
data = service.list_records(zone.id).body.map {|record| record['record']}
load(data)
2011-02-24 20:14:50 -05:00
end
def get(record_id)
requires :zone
data = service.get_record(zone.id, record_id).body["record"]
new(data)
rescue Excon::Errors::NotFound
2011-02-24 20:14:50 -05:00
nil
end
def new(attributes = {})
requires :zone
super({ :zone => zone }.merge!(attributes))
end
end
end
end
end