Class: Fog::Slicehost::DNS::Zone

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/dns/models/slicehost/zone.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

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

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes = {}) ⇒ Zone

Returns a new instance of Zone.



16
17
18
19
20
# File 'lib/fog/dns/models/slicehost/zone.rb', line 16

def initialize(attributes={})
  self.active ||= true
  self.ttl    ||= 3600
  super
end

Instance Method Details

#active=(new_active) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/fog/dns/models/slicehost/zone.rb', line 22

def active=(new_active)
  attributes[:active] = case new_active
  when false, 'N'
    false
  when true, 'Y'
    true
  end
end

#destroyObject



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

def destroy
  requires :identity
  connection.delete_zone(identity)
  true
end

#nameserversObject



46
47
48
49
50
51
52
# File 'lib/fog/dns/models/slicehost/zone.rb', line 46

def nameservers
  [
    'ns1.slicehost.net',
    'ns2.slicehost.net',
    'ns3.slicehost.net'
  ]
end

#recordsObject



37
38
39
40
41
42
43
44
# File 'lib/fog/dns/models/slicehost/zone.rb', line 37

def records
  @records ||= begin
    Fog::Slicehost::DNS::Records.new(
      :zone       => self,
      :connection => connection
    )
  end
end

#saveObject

Raises:



54
55
56
57
58
59
60
61
62
63
# File 'lib/fog/dns/models/slicehost/zone.rb', line 54

def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
  requires :active, :domain, :ttl
  options = {}
  options[:active]  = active ? 'Y' : 'N'
  options[:ttl]     = ttl
  data = connection.create_zone(domain, options)
  merge_attributes(data.body)
  true
end