Module: DummyImage::Middleware

Extended by:
Middleware
Included in:
Middleware
Defined in:
lib/dummy_image/middleware.rb

Constant Summary collapse

IMAGE_DIR =
::File.expand_path("tmp")

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
# File 'lib/dummy_image/middleware.rb', line 6

def call(env)
  requested_path = env["PATH_INFO"]
  env_hash = { "PATH_INFO" => image_path(requested_path),
               "REQUEST_METHOD" => "GET" }
  Rack::File.new(IMAGE_DIR).call( env_hash )
end

#image_path(requested_path) ⇒ Object



13
14
15
16
# File 'lib/dummy_image/middleware.rb', line 13

def image_path(requested_path)
  arguments = RequestParser.new(requested_path)
  Image.find arguments
end