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

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

Instance Method Summary collapse

Methods inherited from Base

#replacements, #resource

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


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

def changed?
  deployed_routes.each do |deployed_route|
    new_route = find_comparable_route(deployed_route)
    if new_route && new_route.to != deployed_route.to
      # change in already deployed route has been detected, requires bluegreen deploy
      return true
    end
  end
  false # Reaching here means no routes have been changed in a way that requires a bluegreen deploy
end

#find_comparable_route(deployed_route) ⇒ Object

Find a route that has the same path and method. This is a comparable route Then we will compare the to or controller action to see if an already deployed route has been changed.



18
19
20
21
22
23
# File 'lib/jets/resource/api_gateway/rest_api/routes/change/to.rb', line 18

def find_comparable_route(deployed_route)
  new_routes.find do |new_route|
    new_route.path == deployed_route.path &&
    new_route.method == deployed_route.method
  end
end