Class: Fog::DNS::Slicehost::Zone
- Inherits:
-
Model
- Object
- Model
- Fog::DNS::Slicehost::Zone
show all
- Defined in:
- lib/fog/slicehost/models/dns/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
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Zone
Returns a new instance of Zone.
16
17
18
19
20
|
# File 'lib/fog/slicehost/models/dns/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/slicehost/models/dns/zone.rb', line 22
def active=(new_active)
attributes[:active] = case new_active
when false, 'N'
false
when true, 'Y'
true
end
end
|
#destroy ⇒ Object
31
32
33
34
35
|
# File 'lib/fog/slicehost/models/dns/zone.rb', line 31
def destroy
requires :identity
connection.delete_zone(identity)
true
end
|
#nameservers ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/fog/slicehost/models/dns/zone.rb', line 46
def nameservers
[
'ns1.slicehost.net',
'ns2.slicehost.net',
'ns3.slicehost.net'
]
end
|
#records ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/fog/slicehost/models/dns/zone.rb', line 37
def records
@records ||= begin
Fog::DNS::Slicehost::Records.new(
:zone => self,
:connection => connection
)
end
end
|
#save ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/fog/slicehost/models/dns/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
|