Class: ZerigoDNS::Zone

Inherits:
Base
  • Object
show all
Defined in:
lib/zerigodns/zone.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#load

Class Method Details

.countFixnum

Get count of all zones

Returns:

  • (Fixnum)

    Count of all zones



5
6
7
# File 'lib/zerigodns/zone.rb', line 5

def count
  get(:count).to_i
end

.find_by_domain(domain) ⇒ Zone

Find zone by domain name

Parameters:

  • domain (String, #read)

    the domain to retrieve

Returns:

  • (Zone)

    the domain retrieved.

Raises:

  • ActiveResource::ResourceNotFound if the domain is not present.



13
14
15
# File 'lib/zerigodns/zone.rb', line 13

def find_by_domain(domain)
  find(domain)
end

.find_or_create(domain) ⇒ Zone

Find or Create Zone

Parameters:

  • domain (String, #read)

    name of domain to create

Returns:

  • (Zone)

    the zone found or created.



20
21
22
23
24
# File 'lib/zerigodns/zone.rb', line 20

def find_or_create(domain)
  find_by_domain(domain)
rescue ActiveResource::ResourceNotFound
  create(:domain=> domain, :ns_type=>'pri_sec')
end

Instance Method Details

#count_hostsFixnum

Get count of all hosts belonging to this zone

Returns:

  • (Fixnum)

    Count of all hosts belonging to this zone.



29
30
31
# File 'lib/zerigodns/zone.rb', line 29

def count_hosts
  get('hosts/count').to_i
end