Class: KubeManifest::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/kube_manifest/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, args, &blk) ⇒ Context

Returns a new instance of Context.



5
6
7
8
# File 'lib/kube_manifest/core.rb', line 5

def initialize(klass, args, &blk)
  @klass, @args, @blk = klass, args, blk
  @cwd, @values = [], {}
end

Instance Attribute Details

#cwdObject

Returns the value of attribute cwd.



3
4
5
# File 'lib/kube_manifest/core.rb', line 3

def cwd
  @cwd
end

#valuesObject

Returns the value of attribute values.



3
4
5
# File 'lib/kube_manifest/core.rb', line 3

def values
  @values
end

Instance Method Details

#as_hashObject



28
29
30
# File 'lib/kube_manifest/core.rb', line 28

def as_hash
  self.evaluate.as_hash
end

#as_yamlObject



32
33
34
# File 'lib/kube_manifest/core.rb', line 32

def as_yaml
  self.evaluate.as_yaml
end

#evaluate(overriding: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kube_manifest/core.rb', line 10

def evaluate(overriding: nil)
  if overriding
    @cwd = overriding.cwd
    @values = overriding.values
  end

  @manifest = @klass.new(ctx: self, values: @values)
  @manifest.instance_eval(&@blk) if @blk
  @args.each_pair do |k, v|
    @manifest.send(k, v)
  end
  @manifest
end