-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move routing constraints to BopsCore engine
This is so they can be reused in other engines.
- Loading branch information
Showing
6 changed files
with
67 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
module BopsCore | ||
module Routing | ||
extend ActiveSupport::Concern | ||
|
||
class LocalAuthoritySubdomain | ||
class << self | ||
def matches?(request) | ||
LocalAuthority.pluck(:subdomain).include?(request.subdomain) | ||
end | ||
end | ||
end | ||
|
||
class ConfigSubdomain | ||
class << self | ||
def matches?(request) | ||
request.subdomain == "config" | ||
end | ||
end | ||
end | ||
|
||
class DeviseSubdomain | ||
class << self | ||
def matches?(request) | ||
ConfigSubdomain.matches?(request) || LocalAuthoritySubdomain.matches?(request) | ||
end | ||
end | ||
end | ||
|
||
class UploadsSubdomain | ||
class << self | ||
def matches?(request) | ||
request.subdomain == "uploads" | ||
end | ||
end | ||
end | ||
|
||
def local_authority_subdomain(&) | ||
constraints(LocalAuthoritySubdomain, &) | ||
end | ||
|
||
def config_subdomain(&) | ||
constraints(ConfigSubdomain, &) | ||
end | ||
|
||
def devise_subdomain(&) | ||
constraints(DeviseSubdomain, &) | ||
end | ||
|
||
def uploads_subdomain(&) | ||
constraints(UploadsSubdomain, &) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.