Class: Fog::DNS::Rackspace::Records

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/rackspace/models/dns/records.rb

Instance Method Summary collapse

Instance Method Details

#allObject



13
14
15
16
17
# File 'lib/fog/rackspace/models/dns/records.rb', line 13

def all
  requires :zone
  data = service.list_records(zone.identity)
  load(data.body['records'])
end

#eachObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/rackspace/models/dns/records.rb', line 20

def each
  requires :zone

  return self unless block_given?

  entries = 0
  begin
    body = service.list_records(zone.id, :offset => entries).body
    entries += body['records'].size

    self.merge_attributes(body)

    subset = dup.load(body['records'])
    subset.each_record_this_page {|record| yield record }

  end while entries < total_entries

  self
end

#each_record_this_pageObject



19
# File 'lib/fog/rackspace/models/dns/records.rb', line 19

alias_method :each_record_this_page, :each

#get(record_id) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/rackspace/models/dns/records.rb', line 40

def get(record_id)
  requires :zone
  data = service.list_record_details(zone.identity, record_id).body
  new(data)
#nil or empty string will trigger an argument error
rescue ArgumentError
  nil
rescue Fog::DNS::Rackspace::NotFound
  nil
end

#new(attributes = {}) ⇒ Object



51
52
53
54
# File 'lib/fog/rackspace/models/dns/records.rb', line 51

def new(attributes = {})
  requires :zone
  super({ :zone => zone }.merge!(attributes))
end