Class: SprinkleDNS::EntryPolicyService

Inherits:
Object
  • Object
show all
Defined in:
lib/sprinkle_dns/entry_policy_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(hosted_zone, configuration) ⇒ EntryPolicyService

Returns a new instance of EntryPolicyService.



3
4
5
6
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 3

def initialize(hosted_zone, configuration)
  @hosted_zone = hosted_zone
  @configuration = configuration
end

Instance Method Details

#compileObject



42
43
44
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 42

def compile
  generate_change_batch
end

#entries_not_touchedObject



16
17
18
19
20
21
22
23
24
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 16

def entries_not_touched
  not_touched = @hosted_zone.entries.select{|hze| hze.referenced? && !hze.changed? && !hze.new?}

  if @configuration.delete?
    not_touched
  else
    (not_touched + @hosted_zone.entries.select{|hze| !hze.referenced?}).flatten
  end
end

#entries_to_changeObject



34
35
36
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 34

def entries_to_change
  [entries_to_create, entries_to_update, entries_to_delete].sum(&:size)
end

#entries_to_change?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 38

def entries_to_change?
  entries_to_change > 0
end

#entries_to_createObject



8
9
10
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 8

def entries_to_create
  @hosted_zone.entries.select{|hze| hze.referenced? && hze.new?}
end

#entries_to_deleteObject



26
27
28
29
30
31
32
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 26

def entries_to_delete
  if @configuration.delete?
    @hosted_zone.entries.select{|hze| !hze.referenced?}
  else
    []
  end
end

#entries_to_updateObject



12
13
14
# File 'lib/sprinkle_dns/entry_policy_service.rb', line 12

def entries_to_update
  @hosted_zone.entries.select{|hze| hze.referenced? && hze.changed? && !hze.new?}
end