Class: Roadworker::Route53Wrapper::ResourceRecordSetCollectionWrapper

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/roadworker/route53-wrapper.rb

Overview

HostedZoneWrapper

Instance Method Summary collapse

Methods included from Log

#log

Constructor Details

#initialize(resource_record_sets, options) ⇒ ResourceRecordSetCollectionWrapper

Returns a new instance of ResourceRecordSetCollectionWrapper.



100
101
102
103
# File 'lib/roadworker/route53-wrapper.rb', line 100

def initialize(resource_record_sets, options)
  @resource_record_sets = resource_record_sets
  @options = options
end

Instance Method Details

#create(name, type, expected_record) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/roadworker/route53-wrapper.rb', line 111

def create(name, type, expected_record)
  log(:info, 'Create ResourceRecordSet', :cyan) do 
    log_id = [name, type].join(' ')
    rrset_setid = expected_record.set_identifier
    rrset_setid ? (log_id + " (#{rrset_setid})") : log_id
  end

  if @options.dry_run
    record = expected_record
  else
    opts = {}

    Route53Wrapper::RRSET_ATTRS.each do |attr|
      value = expected_record.send(attr)
      next unless value

      case attr
      when :dns_name
        attr = :alias_target
        value = @options.route53.dns_name_to_alias_target(value)
      end

      opts[attr] = value
    end

    record = @resource_record_sets.create(name, type, opts)
    @options.updated = true
  end

  ResourceRecordSetWrapper.new(record, @options)
end

#eachObject



105
106
107
108
109
# File 'lib/roadworker/route53-wrapper.rb', line 105

def each
  Collection.batch(@resource_record_sets) do |record|
    yield(ResourceRecordSetWrapper.new(record, @options))
  end
end