class Dbla::Repository

Public Instance Methods

api_key() click to toggle source
# File lib/dbla/repository.rb, line 49
def api_key
  Dbla.config.fetch(:api_key)
end
find(id, params = {}) click to toggle source
# File lib/dbla/repository.rb, line 6
def find id, params = {}
  data = get("#{url}/#{id}?api_key=#{api_key}")
  Response.new(data, params,{})
end
get(uri) click to toggle source
# File lib/dbla/repository.rb, line 41
def get(uri)
  uri = URI(uri)
  Net::HTTP.start(uri.host, uri.port) do |http|
    request = Net::HTTP::Get.new uri
    response = http.request request
    return JSON.parse(response.body)
  end
end
url() click to toggle source
# File lib/dbla/repository.rb, line 53
def url
  # REVIEW: What if the URL does not have a trailing /; Should it be `File.join?`
  @url ||= (Dbla.config.fetch(:url) + blacklight_config.document_model.name.downcase.pluralize).freeze
end