Class: Putpaws::Provision::Resources::Base
- Inherits:
-
Object
- Object
- Putpaws::Provision::Resources::Base
- Defined in:
- lib/putpaws/provision/resources/base.rb
Direct Known Subclasses
Cluster, CodebuildProject, IamRole, LogGroup, SecurityGroup, Service, TaskDefinition
Instance Attribute Summary collapse
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#changed?(_current) ⇒ Boolean
Subclasses implement: name, current, create!, outputs(current) and optionally: changed?(current), update!(current).
-
#ensure! ⇒ Object
Idempotent apply.
-
#initialize(config:, state:, clients:) ⇒ Base
constructor
A new instance of Base.
- #kind ⇒ Object
- #plan ⇒ Object
- #update!(_current) ⇒ Object
Constructor Details
#initialize(config:, state:, clients:) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 |
# File 'lib/putpaws/provision/resources/base.rb', line 8 def initialize(config:, state:, clients:) @config = config @state = state @clients = clients end |
Instance Attribute Details
#clients ⇒ Object (readonly)
Returns the value of attribute clients.
7 8 9 |
# File 'lib/putpaws/provision/resources/base.rb', line 7 def clients @clients end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/putpaws/provision/resources/base.rb', line 7 def config @config end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/putpaws/provision/resources/base.rb', line 7 def state @state end |
Instance Method Details
#changed?(_current) ⇒ Boolean
Subclasses implement: name, current, create!, outputs(current) and optionally: changed?(current), update!(current)
21 22 23 |
# File 'lib/putpaws/provision/resources/base.rb', line 21 def changed?(_current) false end |
#ensure! ⇒ Object
Idempotent apply. Always returns the outputs hash.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/putpaws/provision/resources/base.rb', line 32 def ensure! c = current if c.nil? create! elsif changed?(c) update!(c) else outputs(c) end end |
#kind ⇒ Object
14 15 16 |
# File 'lib/putpaws/provision/resources/base.rb', line 14 def kind self.class.name.split('::').last end |
#plan ⇒ Object
25 26 27 28 29 |
# File 'lib/putpaws/provision/resources/base.rb', line 25 def plan c = current action = c.nil? ? :create : (changed?(c) ? :update : :skip) {action: action, kind: kind, name: name} end |
#update!(_current) ⇒ Object
43 44 45 |
# File 'lib/putpaws/provision/resources/base.rb', line 43 def update!(_current) raise NotImplementedError, "#{kind} does not support update" end |