class Govuk::DummyContentStore::LiveRepository

Attributes

live_content_path[R]

Public Class Methods

new(live_content_path) click to toggle source
# File lib/govuk/dummy_content_store/live_repository.rb, line 6
def initialize(live_content_path)
  @live_content_path = live_content_path
end

Public Instance Methods

find_by_base_path(base_path) click to toggle source
# File lib/govuk/dummy_content_store/live_repository.rb, line 10
def find_by_base_path(base_path)
  res = http_get(base_path)
  res.code == "404" ? nil : res
end

Private Instance Methods

http_get(base_path) click to toggle source
# File lib/govuk/dummy_content_store/live_repository.rb, line 16
def http_get(base_path)
  url = URI.parse(live_content_path + base_path)
  req = Net::HTTP::Get.new(url.to_s)
  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true if url.scheme == "https"
  http.request(req)
end