Class: GdsApi::ContentStore::RedirectResolver
- Inherits:
-
Object
- Object
- GdsApi::ContentStore::RedirectResolver
- Defined in:
- lib/gds_api/content_store.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(content_item, request_path, request_query = "") ⇒ RedirectResolver
constructor
A new instance of RedirectResolver.
Constructor Details
#initialize(content_item, request_path, request_query = "") ⇒ RedirectResolver
Returns a new instance of RedirectResolver.
32 33 34 35 36 |
# File 'lib/gds_api/content_store.rb', line 32 def initialize(content_item, request_path, request_query = "") @content_item = content_item @request_path = request_path @request_query = request_query.to_s end |
Class Method Details
.call(*args) ⇒ Object
38 39 40 |
# File 'lib/gds_api/content_store.rb', line 38 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gds_api/content_store.rb', line 42 def call redirect = redirect_for_path(request_path) raise UnresolvedRedirect, "Could not find a matching redirect" unless redirect destination_uri = URI.parse( resolve_destination(redirect, request_path, request_query), ) url = if destination_uri.absolute? destination_uri.to_s else "#{Plek.new.website_root}#{destination_uri}" end [url, status_code(redirect)] end |