Class: EZDyn::UpdateChange

Inherits:
Change
  • Object
show all
Defined in:
lib/ezdyn/changes.rb

Overview

A pending record update.

Instance Method Summary collapse

Constructor Details

#initialize(records:, new_records:) ⇒ UpdateChange

Returns a new instance of UpdateChange.



70
71
72
73
# File 'lib/ezdyn/changes.rb', line 70

def initialize(records:, new_records:)
  @records = records.map(&:sync!)
  @new_records = new_records
end

Instance Method Details

#to_sString

Returns a string representation of the change.

Returns:

  • (String)

    A string representation of this change.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ezdyn/changes.rb', line 82

def to_s
  ttl_string =
    if @records.map(&:ttl).min == @new_records.map(&:ttl).min
      @records.map(&:ttl).min
    else
      "(( #{@records.map(&:ttl).min} -> #{@new_records.map(&:ttl).min} ))"
    end

  value_string =
    if @records.map(&:value).join(',') == @new_records.map(&:value).join(',')
      @records.map(&:value).join(',')
    else
      "(( #{@records.map(&:value).join(',')} -> #{@new_records.map(&:value).join(',')} ))"
    end

  "UPDATE #{@new_records.first.fqdn}.   #{ttl_string} #{@new_records.first.type}   #{value_string}"
end

#zoneObject



75
76
77
# File 'lib/ezdyn/changes.rb', line 75

def zone
  @new_records.first.zone
end