Class: Roadworker::Batch
- Inherits:
-
Object
- Object
- Roadworker::Batch
- Includes:
- Log
- Defined in:
- lib/roadworker/batch.rb
Defined Under Namespace
Classes: Create, Delete, Operation, Update
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#health_checks ⇒ Object
readonly
Returns the value of attribute health_checks.
-
#hosted_zone ⇒ Object
readonly
Returns the value of attribute hosted_zone.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
Instance Method Summary collapse
- #create(rrset) ⇒ Object
- #delete(rrset) ⇒ Object
-
#initialize(hosted_zone, dry_run:, logger:, health_checks:) ⇒ Batch
constructor
A new instance of Batch.
- #inspect ⇒ Object
-
#request!(route53) ⇒ Boolean
Updated.
- #to_s ⇒ Object
- #update(rrset) ⇒ Object
Methods included from Log
Constructor Details
#initialize(hosted_zone, dry_run:, logger:, health_checks:) ⇒ Batch
Returns a new instance of Batch.
7 8 9 10 11 12 13 14 |
# File 'lib/roadworker/batch.rb', line 7 def initialize(hosted_zone, dry_run:, logger:, health_checks:) @hosted_zone = hosted_zone @dry_run = dry_run @logger = logger @health_checks = health_checks @operations = [] end |
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
17 18 19 |
# File 'lib/roadworker/batch.rb', line 17 def dry_run @dry_run end |
#health_checks ⇒ Object (readonly)
Returns the value of attribute health_checks.
16 17 18 |
# File 'lib/roadworker/batch.rb', line 16 def health_checks @health_checks end |
#hosted_zone ⇒ Object (readonly)
Returns the value of attribute hosted_zone.
16 17 18 |
# File 'lib/roadworker/batch.rb', line 16 def hosted_zone @hosted_zone end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
17 18 19 |
# File 'lib/roadworker/batch.rb', line 17 def logger @logger end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
18 19 20 |
# File 'lib/roadworker/batch.rb', line 18 def operations @operations end |
Instance Method Details
#create(rrset) ⇒ Object
21 22 23 |
# File 'lib/roadworker/batch.rb', line 21 def create(rrset) add_operation Create, rrset end |
#delete(rrset) ⇒ Object
31 32 33 |
# File 'lib/roadworker/batch.rb', line 31 def delete(rrset) add_operation Delete, rrset end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/roadworker/batch.rb', line 48 def inspect "#<#{self.class.name}: #{operations.size} operations>" end |
#request!(route53) ⇒ Boolean
Returns updated.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/roadworker/batch.rb', line 37 def request!(route53) sorted_operations = operations.sort_by(&:sort_key) batches = slice_operations(sorted_operations) batches.each_with_index do |batch, i| dispatch_batch!(route53, batch, i, batches.size) end sorted_operations.any? { |op| !op.changes.empty? } end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/roadworker/batch.rb', line 52 def to_s inspect end |
#update(rrset) ⇒ Object
26 27 28 |
# File 'lib/roadworker/batch.rb', line 26 def update(rrset) add_operation Update, rrset end |