Class: Mystro::Cloud::Dynect::Record

Inherits:
Connect show all
Defined in:
lib/mystro/cloud/connect/dynect/record.rb

Instance Attribute Summary

Attributes inherited from Fog::Connect

#options

Attributes inherited from Connect

#config, #options

Instance Method Summary collapse

Methods inherited from Fog::Connect

#all, #collection, #create, #find, #initialize

Methods inherited from Connect

#all, #create, #encode, #find, #initialize

Constructor Details

This class inherits a constructor from Mystro::Cloud::Fog::Connect

Instance Method Details

#decode(object) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/mystro/cloud/connect/dynect/record.rb', line 29

def decode(object)
  return super unless object.is_a?(Array)
  list = super
  # filter out records that we don't need (TXT, etc)
  list.reject {|e| %w{A CNAME}.include?(e.type) }
  list
end

#destroy(model) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/mystro/cloud/connect/dynect/record.rb', line 14

def destroy(model)
  raise "destroy argument should be Mystro::Cloud::Model: #{model.inspect}" unless model.is_a?(Mystro::Cloud::Model)
  e = find_by_name(model.name)
  Mystro::Log.debug "destroy: #{e.inspect}"
  e._raw.destroy if e && e._raw
  service.publish
end

#find_by_name(name) ⇒ Object



9
10
11
12
# File 'lib/mystro/cloud/connect/dynect/record.rb', line 9

def find_by_name(name)
  #decode(fog.all.detect { |e| e.name == name })
  decode(service.send(collection).find_by_name(name).detect { |e| e.name == name })
end

#serviceObject



22
23
24
25
26
27
# File 'lib/mystro/cloud/connect/dynect/record.rb', line 22

def service
  @service ||= begin
    list = zones.service.zones.all
    list.detect { |e| e.domain == @config[:zone] }
  end
end