Class: Jets::Resource::ApiGateway::RestApi::Routes::Change::Variable

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb

Instance Method Summary collapse

Methods inherited from Base

changed?, #controller_action_from_api, #controller_action_from_string, #get_controller_action, #lambda_function_description, #method_uri, #new_routes, #recreate_path, #recreate_to, #rest_api_id, #to

Methods included from AwsServices

#apigateway, #aws_lambda, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Methods included from AwsServices::GlobalMemoist

included

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 4

def changed?
  changed = false
  deployed_routes.each do |deployed_route|
    parent = collision.variable_parent(deployed_route.path)
    parent_variables = collision.parent_variables(parent, [deployed_route.path])
    new_parent_variables = collision.parent_variables(parent, new_paths)

    changed = parent_variables.size > 0 && new_parent_variables.size > 0 &&
              parent_variables != new_parent_variables
    break if changed
  end
  changed
end

#collisionObject



31
32
33
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 31

def collision
  @collision ||= Jets::Resource::ApiGateway::RestApi::Routes::Collision.new
end

#deployed_routesObject

Only consider deployed routes with variables



24
25
26
27
28
29
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 24

def deployed_routes
  deployed_routes = super
  deployed_routes.select do |route|
    route.path.include?(':')
  end
end

#new_pathsObject

Only consider paths with variables



19
20
21
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 19

def new_paths
  new_routes.map(&:path).select {|p| p.include?(':')}.uniq
end