Class: EZDyn::UpdateChange
Overview
A pending record update.
Instance Method Summary collapse
-
#initialize(records:, new_records:) ⇒ UpdateChange
constructor
A new instance of UpdateChange.
-
#to_s ⇒ String
Returns a string representation of the change.
- #zone ⇒ Object
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_s ⇒ String
Returns a string representation of the 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 |
#zone ⇒ Object
75 76 77 |
# File 'lib/ezdyn/changes.rb', line 75 def zone @new_records.first.zone end |