Class: ArgumentTemplateParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/ccios/argument_template_parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameter_template_definition_hash) ⇒ ArgumentTemplateParameter

Returns a new instance of ArgumentTemplateParameter.



4
5
6
7
8
9
10
11
12
13
# File 'lib/ccios/argument_template_parameter.rb', line 4

def initialize(parameter_template_definition_hash)
  @name = parameter_template_definition_hash["argument"]
  @description = parameter_template_definition_hash["description"] || ""
  @template_variable_name = parameter_template_definition_hash["template_variable_name"] || @name
  @removeSuffix = parameter_template_definition_hash["removeSuffix"] || ""
  @lowercased_name = parameter_template_definition_hash["lowercased_variable_name"] || ""

  raise "Missing argument name" if @name.nil? || @name.empty?
  raise "Invalid argument template_variable_name for #{@name}" if @template_variable_name.nil? || template_variable_name.empty?
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



2
3
4
# File 'lib/ccios/argument_template_parameter.rb', line 2

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/ccios/argument_template_parameter.rb', line 2

def name
  @name
end

#template_variable_nameObject (readonly)

Returns the value of attribute template_variable_name.



2
3
4
# File 'lib/ccios/argument_template_parameter.rb', line 2

def template_variable_name
  @template_variable_name
end

Instance Method Details

#provided_context_keysObject



26
27
28
29
30
31
32
# File 'lib/ccios/argument_template_parameter.rb', line 26

def provided_context_keys
  context_keys = [@template_variable_name]
  if !@lowercased_name.empty?
    context_keys.append(@lowercased_name)
  end
  context_keys
end

#update_context(context) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/ccios/argument_template_parameter.rb', line 15

def update_context(context)
  if !@removeSuffix.empty?
    value = context[@template_variable_name]
    context[@template_variable_name] = value.gsub(@removeSuffix, "")
  end
  if !@lowercased_name.empty? && !context[@lowercased_name]
    context[@lowercased_name] = context[@template_variable_name].camelize(:lower)
  end
  context
end