Class: Fog::DNS::Rage4::Record

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

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

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(attributes = {}) ⇒ Record

Returns a new instance of Record.



28
29
30
# File 'lib/fog/rage4/models/dns/record.rb', line 28

def initialize(attributes={})
  super
end

Instance Method Details

#destroyObject



36
37
38
39
# File 'lib/fog/rage4/models/dns/record.rb', line 36

def destroy
  service.delete_record(id)
  true
end

#domainObject



32
33
34
# File 'lib/fog/rage4/models/dns/record.rb', line 32

def domain
  name
end

#saveObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/rage4/models/dns/record.rb', line 45

def save
  requires :name, :type, :value
  options = {}
  options[:priority] = priority if priority
  options[:ttl]  = ttl if ttl
  options[:geozone] = geo_region_id if geo_region_id
  options[:geolock] = geo_lock if geo_lock
  options[:geolat] = geo_lat if geo_lat
  options[:geolong] = geo_long if geo_long

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

  merge_attributes(options)
  merge_attributes(:name =>  name, :value => value, :type => type)
  true
end

#zoneObject



41
42
43
# File 'lib/fog/rage4/models/dns/record.rb', line 41

def zone
  @zone
end