lib/fog/zerigo/models/dns/records.rb in fog-1.10.0 vs lib/fog/zerigo/models/dns/records.rb in fog-1.10.1
- old
+ new
@@ -8,19 +8,27 @@
class Records < Fog::Collection
attribute :zone
model Fog::DNS::Zerigo::Record
-
- def all
+
+ # List all domains
+ # @param [Hash] options Options to pass to the underlying API call
+ # @option options [String] :fqdn search for the given fqdn
+ def all(options = {})
requires :zone
- parent = zone.collection.get(zone.identity)
- if parent
- merge_attributes(parent.records.attributes)
- load(parent.records.map {|record| record.attributes})
+ if options[:fqdn]
+ hosts = service.find_hosts(options[:fqdn], zone.id).body['hosts']
+ load(hosts)
else
- nil
+ parent = zone.collection.get(zone.identity)
+ if parent
+ merge_attributes(parent.records.attributes)
+ load(parent.records.map {|record| record.attributes})
+ else
+ nil
+ end
end
end
def get(record_id)
data = service.get_host(record_id).body
@@ -30,14 +38,9 @@
end
def new(attributes = {})
requires :zone
super({ :zone => zone }.merge!(attributes))
- end
-
- def find(fqdn)
- hosts = service.find_hosts(fqdn, zone.id).body['hosts']
- hosts.collect { |host| new(host) }
end
end
end