Class: Fog::DNS::DNSimple::Record

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Record

Returns a new instance of Record.



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

def initialize(attributes={})
  super
end

Instance Method Details

#destroyObject



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

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

#saveObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/dnsimple/models/dns/record.rb', line 35

def save
  requires :name, :type, :value
  options = {}
  options[:prio] = priority if priority
  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["record"])
  true
end

#zoneObject



31
32
33
# File 'lib/fog/dnsimple/models/dns/record.rb', line 31

def zone
  @zone
end