lib/punky_brewster/server.rb in punky_brewster-1.3.1 vs lib/punky_brewster/server.rb in punky_brewster-1.3.2
- old
+ new
@@ -1,22 +1,26 @@
require 'json'
require 'punky_brewster'
module PunkyBrewster
class Server
- def self.call(env)
+
+ def call(env)
headers = { 'Content-Type' => 'application/json' }
begin
- beers = BeerListRequest.new.beers
- beers_properties = beers.map(&:to_h)
- body = JSON.generate(beers_properties)
+ body = BeerRepository.list.to_json
status = 200
rescue => error
body = JSON.generate(error: "#{error.class}: #{error}")
status = 500
end
[status, headers, [body]]
end
+
+ def self.call(env)
+ self.new.call(env)
+ end
+
end
end