Class: Kerbi::State::BaseBackend

Inherits:
Object
  • Object
show all
Defined in:
lib/state/base_backend.rb

Direct Known Subclasses

ConfigMapBackend

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseBackend

Returns a new instance of BaseBackend.



15
16
# File 'lib/state/base_backend.rb', line 15

def initialize(options={})
end

Instance Attribute Details

#is_workingTrueClass|FalseClass (readonly)

Whether the last connection attempt succeeded or failed

Returns:

  • (TrueClass|FalseClass)

    list of hashes



13
14
15
# File 'lib/state/base_backend.rb', line 13

def is_working
  @is_working
end

#release_nameString (readonly)

Made available to states, as a convenience

Returns:

  • (String)

    release name



8
9
10
# File 'lib/state/base_backend.rb', line 8

def release_name
  @release_name
end

Class Method Details

.type_signatureObject

Raises:

  • (NotImplementedError)


70
71
72
# File 'lib/state/base_backend.rb', line 70

def self.type_signature
  raise NotImplementedError
end

Instance Method Details

#deleteObject



46
47
48
# File 'lib/state/base_backend.rb', line 46

def delete
  delete_resource
end

#delete_entry(entry) ⇒ Object

Parameters:



32
33
34
35
36
37
# File 'lib/state/base_backend.rb', line 32

def delete_entry(entry)
  entries.reject! { |e| e.tag == entry.tag }
  save
  @_entry_set = nil
  @_resource = nil
end

#entriesArray<Kerbi::State::Entry>

Returns:



27
28
29
# File 'lib/state/base_backend.rb', line 27

def entries
  entry_set.entries
end

#entry_setKerbi::State::EntrySet



19
20
21
22
23
24
# File 'lib/state/base_backend.rb', line 19

def entry_set
  @_entry_set ||= EntrySet.new(
    read_entries,
    release_name: release_name
  )
end

#primeObject



54
55
56
57
58
59
60
61
62
# File 'lib/state/base_backend.rb', line 54

def prime
  begin
    resource
    entries
    @is_working = true
  rescue
    @is_working = false
  end
end

#resource_signatureObject

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/state/base_backend.rb', line 50

def resource_signature
  raise NotImplementedError
end

#saveObject



39
40
41
42
43
44
# File 'lib/state/base_backend.rb', line 39

def save
  entry_set.validate!
  update_resource
  @_entry_set = nil
  @_resource = nil
end

#working?TrueClass|FalseClass

Returns:

  • (TrueClass|FalseClass)


65
66
67
68
# File 'lib/state/base_backend.rb', line 65

def working?
  prime if @is_working.nil?
  @is_working
end