Class: Cumulus::Route53::RecordDiff

Inherits:
Common::Diff show all
Includes:
RecordChange
Defined in:
lib/route53/models/RecordDiff.rb

Overview

Public: Represents differences between local configuration and AWS configuration for records.

Constant Summary

Constants included from RecordChange

Cumulus::Route53::RecordChange::ALIAS, Cumulus::Route53::RecordChange::CHANGED, Cumulus::Route53::RecordChange::DEFAULT, Cumulus::Route53::RecordChange::IGNORED, Cumulus::Route53::RecordChange::TTL, Cumulus::Route53::RecordChange::VALUE

Constants included from Common::DiffChange

Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED

Instance Attribute Summary collapse

Attributes inherited from Common::Diff

#aws, #info_only, #local, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::DiffChange

next_change_id

Methods inherited from Common::Diff

#add_string, added, #initialize, modified, #to_s, unmanaged, #unmanaged_string

Constructor Details

This class inherits a constructor from Cumulus::Common::Diff

Instance Attribute Details

#changesObject

Returns the value of attribute changes.



25
26
27
# File 'lib/route53/models/RecordDiff.rb', line 25

def changes
  @changes
end

#messageObject

Returns the value of attribute message.



24
25
26
# File 'lib/route53/models/RecordDiff.rb', line 24

def message
  @message
end

Class Method Details

.changed(changes, local) ⇒ Object

Public: Static method that will create a diff that contains a bunch of singular changes.

changes - the changes for the record local - the local configuration for the record

Returns the diff



61
62
63
64
65
# File 'lib/route53/models/RecordDiff.rb', line 61

def self.changed(changes, local)
  diff = RecordDiff.new(CHANGED, nil, local)
  diff.changes = changes
  diff
end

.default(message, aws) ⇒ Object

Public: Static method that will create a diff that contains a message but is ignored when syncing because it is a default record.

message - the message to display aws - the aws configuration for the record

Returns the diff



34
35
36
37
38
# File 'lib/route53/models/RecordDiff.rb', line 34

def self.default(message, aws)
  diff = RecordDiff.new(DEFAULT, aws)
  diff.message = message
  diff
end

.ignored(message, aws) ⇒ Object

Public: Static method that will create a diff that contains a message but is ignored when syncing.

message - the message to display aws - the aws configuration for the record

Returns the diff



47
48
49
50
51
52
# File 'lib/route53/models/RecordDiff.rb', line 47

def self.ignored(message, aws)
  diff = RecordDiff.new(IGNORED, aws)
  diff.message = message
  diff.info_only = true
  diff
end

Instance Method Details

#asset_typeObject



67
68
69
# File 'lib/route53/models/RecordDiff.rb', line 67

def asset_type
  "Record"
end

#aws_nameObject



71
72
73
# File 'lib/route53/models/RecordDiff.rb', line 71

def aws_name
  "(#{@aws.type}) #{@aws.name}"
end

#diff_stringObject



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/route53/models/RecordDiff.rb', line 79

def diff_string
  case @type
  when IGNORED
    message
  when DEFAULT
    message
  when CHANGED
    [
      "Record #{local_name}:",
      changes.map { |c| "\t\t#{c}" }
    ].flatten.join("\n")
  end
end

#local_nameObject



75
76
77
# File 'lib/route53/models/RecordDiff.rb', line 75

def local_name
  @local.readable_name
end