From b8ee33b8e38911012fc055f02da1878e45eb721a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 23 Nov 2010 12:17:24 -0800 Subject: split out common read/write code It will be useful when we support other backends. --- lib/metropolis/tc/hdb.rb | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'lib/metropolis/tc/hdb.rb') diff --git a/lib/metropolis/tc/hdb.rb b/lib/metropolis/tc/hdb.rb index ec387b4..4c58ca8 100644 --- a/lib/metropolis/tc/hdb.rb +++ b/lib/metropolis/tc/hdb.rb @@ -6,14 +6,7 @@ module Metropolis::TC::HDB autoload :RO, 'metropolis/tc/hdb/ro' TCHDB = TokyoCabinet::HDB # :nodoc - include Rack::Utils # unescape - - def r(code) - body = "#{HTTP_STATUS_CODES[code]}\n" - [ code, - { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/plain' }, - [ body ] ] - end + include Metropolis::Common def setup(opts) @headers = { 'Content-Type' => 'application/octet-stream' } @@ -64,25 +57,6 @@ module Metropolis::TC::HDB end end - def call(env) - if %r{\A/(.*)\z} =~ env["PATH_INFO"] - key = unescape($1) - case env["REQUEST_METHOD"] - when "GET" - get(key) - when "HEAD" - head(key) - when "DELETE" - delete(key) - when "PUT" - put(key, env) - else - [ 405, {}, [] ] - end - else # OPTIONS - [ 405, {}, [] ] - end - end def ex!(msg, hdb) raise "#{msg}: #{hdb.errmsg(hdb.ecode)}" -- cgit v1.2.3-24-ge0c7