class Fog::DNS::Softlayer::Record

Public Class Methods

new(attributes={}) click to toggle source
Calls superclass method
# File lib/fog/softlayer/models/dns/record.rb, line 24
def initialize(attributes={})
  self.domain_id = attributes[:domain_id]
  super(attributes)
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/softlayer/models/dns/record.rb, line 29
def destroy
  response = service.delete_record(identity)
  response.body
end
save() click to toggle source
# File lib/fog/softlayer/models/dns/record.rb, line 34
def save
  requires :name, :type, :value, :domain_id
  opts = generate_template

  # to save or to update, thats the question
  if id.nil?
    data = service.create_record(opts)
    merge_attributes(data.body)
  else
    data = service.update_record(self.id, opts)
  end
  true
end

Private Instance Methods

generate_template() click to toggle source
# File lib/fog/softlayer/models/dns/record.rb, line 49
def generate_template
  template = {}
  template[:host] = self.name
  template[:data] = self.value
  template[:type] = self.type
  template[:domainId] = self.domain_id

  template[:ttl] = self.ttl if self.ttl
  template[:mxPriority] = self.priority if self.priority
  template[:expire] = self.expire if self.expire
  template[:minimum] = self.minimum if self.minimum
  template[:refresh] = self.refresh if self.refresh
  template[:retry] = self.retry if self.retry
  template
end