Class: Fog::DNS::Dreamhost::Zones

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/dreamhost/models/dns/zones.rb

Overview

Dreamhost API has no concept of ‘Zone’, but we can emulate it.

wiki.dreamhost.com/API/Dns_commands

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#allObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/dreamhost/models/dns/zones.rb', line 18

def all
  clear
  zones = []
  zones_added = []
  service.records.each do |r|
    unless zones_added.include?(r.zone)
      zones << { :id => r.zone, :domain => r.zone }
      zones_added << r.zone
    end
  end
  load(zones)
end

#get(zone_id) ⇒ Object



31
32
33
34
35
# File 'lib/fog/dreamhost/models/dns/zones.rb', line 31

def get(zone_id)
  service.zones.find { |z| z.domain == zone_id }
rescue Excon::Errors::NotFound
  nil
end