Class: Mugshot::HTTPStorage

Inherits:
Storage
  • Object
show all
Defined in:
lib/mugshot/http_storage.rb

Instance Method Summary collapse

Methods inherited from Storage

#write

Instance Method Details

#read(id) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/mugshot/http_storage.rb', line 7

def read(id)
  url = URI.parse(@url_resolver.call(id))
  res = Net::HTTP.start(url.host, url.port) {|http| http.get(url.path)}

  return nil unless res.code.to_i == 200

  Mugshot::Image.new(res.body)
end