Method: Jets::Resource::ApiGateway::Method#method_logical_id

Defined in:
lib/jets/resource/api_gateway/method.rb

#method_logical_idObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jets/resource/api_gateway/method.rb', line 34

def method_logical_id
  # https://stackoverflow.com/questions/6104240/how-do-i-strip-non-alphanumeric-characters-from-a-string-and-keep-spaces
  # Add path to the logical id to allow 2 different paths to be connected to the same controller action.
  # Example:
  #
  #   root "jets/public#show"
  #   any "*catchall", to: "jets/public#show"
  #
  # Without the path in the logical id, the logical id would be ShowApiMethod for both routes and only the
  # last one would be created in the CloudFormation template.
  path = @route.path.gsub('*','')
          .gsub(/[^0-9a-z]/i, ' ')
          .gsub(/\s+/, '_')
  path = nil if path == ''
  http_verb = @route.method.downcase
  [path, "{namespace}_#{http_verb}_api_method"].compact.join('_')
end