Class: Highlander::Dsl::Parameters

Inherits:
DslBase
  • Object
show all
Defined in:
lib/highlander.dsl.params.rb

Instance Attribute Summary collapse

Attributes inherited from DslBase

#config

Instance Method Summary collapse

Methods inherited from DslBase

#method_missing

Constructor Details

#initialize ⇒ Parameters

Returns a new instance of Parameters.



10
11
12
# File 'lib/highlander.dsl.params.rb', line 10

def initialize()
  @param_list = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Highlander::Dsl::DslBase

Instance Attribute Details

#param_list ⇒ Object

Returns the value of attribute param_list.



8
9
10
# File 'lib/highlander.dsl.params.rb', line 8

def param_list
  @param_list
end

Instance Method Details

#addParam(param) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/highlander.dsl.params.rb', line 14

def addParam(param)
  existing_param = @param_list.find { |p| p.name == param.name }
  if not existing_param.nil?
    puts "Parameter being overwritten. Updating parameter #{param.name} with new definition..."
    @param_list[@param_list.index(existing_param)] = param
  else
    @param_list << param
  end
end

#ComponentParam(name, defaultValue = '') ⇒ Object



32
33
34
35
36
# File 'lib/highlander.dsl.params.rb', line 32

def ComponentParam(name, defaultValue='')
  param = ComponentParam.new(name, 'String', defaultValue)
  param.config = @config
  addParam param
end

#MappingParam(name, defaultValue = '', &block) ⇒ Object



38
39
40
41
42
43
# File 'lib/highlander.dsl.params.rb', line 38

def MappingParam(name, defaultValue='', &block)
  param = MappingParam.new(name, 'String', defaultValue)
  param.config = @config
  param.instance_eval(&block)
  addParam param
end

#OutputParam(component:, name:, default: '') ⇒ Object



45
46
47
48
49
# File 'lib/highlander.dsl.params.rb', line 45

def OutputParam(component:, name:, default: '')
  param = OutputParam.new(component, name, default)
  param.config = @config
  addParam param
end

#StackParam(name, defaultValue = '', isGlobal: false, noEcho: false) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/highlander.dsl.params.rb', line 24

def StackParam(name, defaultValue='', isGlobal: false, noEcho: false)
  param = StackParam.new(name, 'String', defaultValue)
  param.is_global = isGlobal
  param.config = @config
  param.no_echo = noEcho
  addParam param
end