Class: Awshark::CloudFormation::Parameters

Inherits:
Object
  • Object
show all
Includes:
Files
Defined in:
lib/awshark/cloud_formation/parameters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Files

#parse_file, #parse_string

Constructor Details

#initialize(path:, stage: nil) ⇒ Parameters

Returns a new instance of Parameters.



10
11
12
13
14
15
# File 'lib/awshark/cloud_formation/parameters.rb', line 10

def initialize(path:, stage: nil)
  @filepath = Dir.glob("#{path}/parameters.*").detect do |f|
    %w[.json .yml .yaml].include?(File.extname(f))
  end
  @stage = stage
end

Instance Attribute Details

#stageObject (readonly)

Returns the value of attribute stage.



8
9
10
# File 'lib/awshark/cloud_formation/parameters.rb', line 8

def stage
  @stage
end

Instance Method Details

#paramsObject



17
18
19
# File 'lib/awshark/cloud_formation/parameters.rb', line 17

def params
  @params ||= load_parameters(@filepath)
end

#stack_parametersObject



25
26
27
28
29
30
31
32
# File 'lib/awshark/cloud_formation/parameters.rb', line 25

def stack_parameters
  params.each.map do |k, v|
    {
      parameter_key: k,
      parameter_value: v
    }
  end
end

#to_hashObject



21
22
23
# File 'lib/awshark/cloud_formation/parameters.rb', line 21

def to_hash
  params
end