class Determinator::Retrieve::HttpRetriever

Public Class Methods

new(connection:) click to toggle source
# File lib/determinator/retrieve/http_retriever.rb, line 7
def initialize(connection:)
  raise ArgumentError, "client must be a Faraday::Connection" unless connection.is_a?(Faraday::Connection)
  @connection = connection
end

Public Instance Methods

get_name(url) click to toggle source

Returns a feature name given a actor-tracking url. Used so we are able to expire a cache using a feature name given an event url.

Not intended to be generic, and makes no guarantees about support for alternative url schemes.

@param url [String] a actor tracking url @return [String, nil] a feature name or nil

# File lib/determinator/retrieve/http_retriever.rb, line 29
def get_name(url)
  (url.match('features\/(.*)\z') || [])[1]
end
retrieve(name) click to toggle source
# File lib/determinator/retrieve/http_retriever.rb, line 12
def retrieve(name)
  response = @connection.get("/features/#{name}")
  return Determinator::Serializers::JSON.load(response.body) if response.status == 200
  return MissingResponse.new if response.status == 404
rescue => e
  Determinator.notice_error(e)
  ErrorResponse.new
end