Class: Kubes::Args::Custom

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
DslEvaluator, Dsl
Defined in:
lib/kubes/args/custom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dsl

#command, #each_command

Constructor Details

#initialize(name, file) ⇒ Custom

Returns a new instance of Custom.



8
9
10
11
12
# File 'lib/kubes/args/custom.rb', line 8

def initialize(name, file)
  @name = name.to_s
  @file = file # IE: .kubes/config/kubectl/args.rb
  @commands = {}
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/kubes/args/custom.rb', line 7

def name
  @name
end

Instance Method Details

#argsObject



21
22
23
24
# File 'lib/kubes/args/custom.rb', line 21

def args
  args = dig("args")
  args.compact.flatten
end

#buildObject



14
15
16
17
18
# File 'lib/kubes/args/custom.rb', line 14

def build
  return @commands unless File.exist?(@file)
  evaluate_file(@file)
  @commands.deep_stringify_keys!
end

#dig(prop, default = []) ⇒ Object



26
27
28
# File 'lib/kubes/args/custom.rb', line 26

def dig(prop, default=[])
  @commands.dig(@name, prop) || default
end