Class: Gcloud::Dns::Zone::Transaction
- Inherits:
-
Object
- Object
- Gcloud::Dns::Zone::Transaction
- Defined in:
- lib/gcloud/dns/zone/transaction.rb
Overview
# DNS Zone Transaction
This object is used by #update when passed a block. These methods are used to update the records that are sent to the Google Cloud DNS API.
Instance Attribute Summary collapse
- #additions ⇒ Object readonly
- #deletions ⇒ Object readonly
Instance Method Summary collapse
-
#add(name, type, ttl, data) ⇒ Object
Adds a record to the Zone.
-
#initialize(zone) ⇒ Transaction
constructor
A new instance of Transaction.
-
#modify(name, type) {|record| ... } ⇒ Object
Modifies records on the Zone.
-
#remove(name, type) ⇒ Object
Removes records from the Zone.
-
#replace(name, type, ttl, data) ⇒ Object
Replaces existing records on the Zone.
Constructor Details
#initialize(zone) ⇒ Transaction
Returns a new instance of Transaction.
48 49 50 51 52 |
# File 'lib/gcloud/dns/zone/transaction.rb', line 48 def initialize zone @zone = zone @additions = [] @deletions = [] end |
Instance Attribute Details
#additions ⇒ Object (readonly)
44 45 46 |
# File 'lib/gcloud/dns/zone/transaction.rb', line 44 def additions @additions end |
#deletions ⇒ Object (readonly)
44 45 46 |
# File 'lib/gcloud/dns/zone/transaction.rb', line 44 def deletions @deletions end |
Instance Method Details
#add(name, type, ttl, data) ⇒ Object
Adds a record to the Zone.
81 82 83 |
# File 'lib/gcloud/dns/zone/transaction.rb', line 81 def add name, type, ttl, data @additions += Array(@zone.record(name, type, ttl, data)) end |
#modify(name, type) {|record| ... } ⇒ Object
Modifies records on the Zone. Records matching the ‘name` and `type` are yielded to the block where they can be modified.
166 167 168 169 170 171 172 |
# File 'lib/gcloud/dns/zone/transaction.rb', line 166 def modify name, type existing = @zone.records(name, type).all.to_a updated = existing.map(&:dup) updated.each { |r| yield r } @additions += updated @deletions += existing end |
#remove(name, type) ⇒ Object
Removes records from the Zone. The records are looked up before they are removed.
105 106 107 |
# File 'lib/gcloud/dns/zone/transaction.rb', line 105 def remove name, type @deletions += @zone.records(name, type).all end |
#replace(name, type, ttl, data) ⇒ Object
Replaces existing records on the Zone. Records matching the ‘name` and `type` are replaced.
138 139 140 141 |
# File 'lib/gcloud/dns/zone/transaction.rb', line 138 def replace name, type, ttl, data remove name, type add name, type, ttl, data end |