Class: WebFetch::Retriever

Inherits:
Object
  • Object
show all
Includes:
Validatable
Defined in:
lib/web_fetch/retriever.rb

Overview

Retrieves a gathered HTTP request

Instance Attribute Summary collapse

Attributes included from Validatable

#errors

Instance Method Summary collapse

Methods included from Validatable

#valid?

Constructor Details

#initialize(server, params, options) ⇒ Retriever

Returns a new instance of Retriever.



10
11
12
13
14
15
# File 'lib/web_fetch/retriever.rb', line 10

def initialize(server, params, options)
  @uid = params[:uid]
  @hash = params[:hash]
  @server = server
  @block = options.fetch(:block, true)
end

Instance Attribute Details

#not_found_errorObject (readonly)

Returns the value of attribute not_found_error.



8
9
10
# File 'lib/web_fetch/retriever.rb', line 8

def not_found_error
  @not_found_error
end

Instance Method Details

#findObject



17
18
19
20
21
22
23
24
# File 'lib/web_fetch/retriever.rb', line 17

def find
  request = @server.storage.fetch(@uid)
  return not_found if request.nil?
  return not_found if request.nil?
  return request.merge(pending: true) if pending?(request)

  request
end