Class: Fog::DNS::Dnsimple::Record

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Record

Returns a new instance of Record.



18
19
20
# File 'lib/fog/dnsimple/models/dns/record.rb', line 18

def initialize(attributes = {})
  super
end

Instance Method Details

#destroyObject



22
23
24
25
# File 'lib/fog/dnsimple/models/dns/record.rb', line 22

def destroy
  service.delete_record(zone.id, identity)
  true
end

#saveObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/dnsimple/models/dns/record.rb', line 31

def save
  requires :name, :type, :value
  options = {}
  options[:ttl] = ttl if ttl

  # decide whether its a new record or update of an existing
  if id.nil?
    data = service.create_record(zone.id, name, type, value, options)
  else
    options[:name] = name if name
    options[:content] = value if value
    options[:type] = type if type
    data = service.update_record(zone.id, id, options)
  end

  merge_attributes(data.body["data"])
  true
end

#zoneObject



27
28
29
# File 'lib/fog/dnsimple/models/dns/record.rb', line 27

def zone
  @zone
end