Module: Rack::MogileFS::Endpoint::Mapper

Included in:
Rack::MogileFS::Endpoint
Defined in:
lib/rack/mogilefs/endpoint/mapper.rb

Overview

Adds ability to pass in a custom mapper to map PATH_INFO to a MogileFS key. By default it is assumed that the path is the same as the key. For example your keys will look like this:

"/assets/images/myimage.gif"

Create a custom mapper like this:

Rack::MogileFS::Endpoint.new(
  :mapper => lambda { |path| "/namespace/" + path }
)

Instance Method Summary collapse

Instance Method Details

#key_for_path(path) ⇒ Object



17
18
19
20
# File 'lib/rack/mogilefs/endpoint/mapper.rb', line 17

def key_for_path(path)
  @options[:mapper].respond_to?(:call) ?
  @options[:mapper].call(path) : super
end