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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#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, #cfn, #lambda, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Class Method Details

.changed?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 4

def self.changed?
  new.changed?
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 8

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



35
36
37
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 35

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

#deployed_routesObject

Only consider deployed routes with variables



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

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

#new_pathsObject

Only consider paths with variables



23
24
25
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb', line 23

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