Class: Convection::Model::Template::Parameter

Inherits:
Object
  • Object
show all
Includes:
DSL::Helpers
Defined in:
lib/convection/model/template/parameter.rb

Overview

Template Parameter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL::Helpers

#camel_case, included, method_name, #screaming_snake_case, #snake_case

Methods included from DSL::IntrinsicFunctions

#base64, #find_in_map, #fn_and, #fn_equals, #fn_if, #fn_not, #fn_or, #fn_ref, #get_att, #get_azs, #join, #select

Constructor Details

#initialize(name, parent) ⇒ Parameter

Returns a new instance of Parameter



26
27
28
29
30
31
32
33
34
# File 'lib/convection/model/template/parameter.rb', line 26

def initialize(name, parent)
  @name = name
  @template = parent.template

  @type = 'String'
  @default = ''
  @allowed_values = []
  @description = ''
end

Instance Attribute Details

#allowed_valuesObject (readonly)

Returns the value of attribute allowed_values



17
18
19
# File 'lib/convection/model/template/parameter.rb', line 17

def allowed_values
  @allowed_values
end

#templateObject (readonly)

Returns the value of attribute template



15
16
17
# File 'lib/convection/model/template/parameter.rb', line 15

def template
  @template
end

Instance Method Details

#allow(value) ⇒ Object



36
37
38
# File 'lib/convection/model/template/parameter.rb', line 36

def allow(value)
  allowed_values << value
end

#renderObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/convection/model/template/parameter.rb', line 40

def render
  {
    'Type' => type,
    'Default' => default,
    'Description' => description
  }.tap do |resource|
    resource['AllowedValues'] = allowed_values unless allowed_values.empty?
    resource['AllowedPattern'] = allowed_pattern unless allowed_pattern.nil?
    resource['MaxLength'] = max_length unless max_length.nil?
    resource['MinLength'] = min_length unless min_length.nil?
    resource['MaxValue'] = max_value unless max_value.nil?
    resource['MinValue'] = min_value unless min_value.nil?
    resource['NoEcho'] = no_echo unless no_echo.nil?
    resource['ConstraintDescription'] = constraint_description unless constraint_description.nil?
  end
end