Module: Rack::GridFS::Endpoint::Base
- Included in:
- Rack::GridFS::Endpoint
- Defined in:
- lib/rack/gridfs/endpoint/base.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
5 6 7 |
# File 'lib/rack/gridfs/endpoint/base.rb', line 5 def db @db end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/gridfs/endpoint/base.rb', line 16 def call(env) with_rescues do request = Rack::Request.new(env) key = key_for_path(request.path_info) file = find_file(key) response_for(file, request) end end |
#initialize(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/rack/gridfs/endpoint/base.rb', line 7 def initialize( = {}) @options = .merge() @db = @options[:db] @lookup = @options[:lookup] @mapper = @options[:mapper] @fs_name = @options[:fs_name] end |
#key_for_path(path) ⇒ Object
26 27 28 |
# File 'lib/rack/gridfs/endpoint/base.rb', line 26 def key_for_path(path) @mapper.respond_to?(:call) ? @mapper.call(path) : path end |