Sha256: 9017e160e5a2a23662dcc27575c26e536fc892ebb62bc8692581d5d83e57a9ce

Contents?: true

Size: 1.65 KB

Versions: 100

Compression:

Stored size: 1.65 KB

Contents

require_relative '../../dsl/intrinsic_functions'

module Convection
  module Model
    class Template
      ##
      # Template Parameter
      ##
      class Parameter
        include DSL::Helpers

        attribute :type
        attribute :default
        attribute :description
        attr_reader :template

        attr_reader :allowed_values
        attribute :allowed_pattern
        attribute :no_echo
        attribute :max_length
        attribute :min_length
        attribute :max_value
        attribute :min_value
        attribute :constraint_description

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

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

        def allow(value)
          allowed_values << value
        end

        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
      end
    end
  end
end

Version data entries

100 entries across 100 versions & 1 rubygems

Version Path
convection-2.3.1 lib/convection/model/template/parameter.rb
convection-2.3.0 lib/convection/model/template/parameter.rb
convection-2.2.29 lib/convection/model/template/parameter.rb
convection-2.2.28.pre.beta.2 lib/convection/model/template/parameter.rb
convection-2.2.28.pre.beta.1 lib/convection/model/template/parameter.rb
convection-2.2.27 lib/convection/model/template/parameter.rb
convection-2.2.26 lib/convection/model/template/parameter.rb
convection-2.2.25 lib/convection/model/template/parameter.rb
convection-2.2.24 lib/convection/model/template/parameter.rb
convection-2.2.23 lib/convection/model/template/parameter.rb
convection-2.2.22 lib/convection/model/template/parameter.rb
convection-2.2.21 lib/convection/model/template/parameter.rb
convection-2.2.20 lib/convection/model/template/parameter.rb
convection-2.2.19 lib/convection/model/template/parameter.rb
convection-2.2.18 lib/convection/model/template/parameter.rb
convection-2.2.17 lib/convection/model/template/parameter.rb
convection-2.2.16 lib/convection/model/template/parameter.rb
convection-2.2.15 lib/convection/model/template/parameter.rb
convection-2.2.14 lib/convection/model/template/parameter.rb
convection-2.2.13 lib/convection/model/template/parameter.rb