Class: Hanami::Action::Rack::File Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/action/rack/file.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

File to be sent

See Also:

Since:

  • 0.4.3

Instance Method Summary collapse

Constructor Details

#initialize(path, root) ⇒ File

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of File.

Parameters:

  • path (String, Pathname)

    file path

Since:

  • 0.4.3



23
24
25
26
# File 'lib/hanami/action/rack/file.rb', line 23

def initialize(path, root)
  @file = ::Rack::File.new(root.to_s)
  @path = path.to_s
end

Instance Method Details

#call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.3



30
31
32
33
34
35
36
37
# File 'lib/hanami/action/rack/file.rb', line 30

def call(env)
  env = env.dup
  env[Action::PATH_INFO] = @path

  @file.get(env)
rescue Errno::ENOENT
  [Action::NOT_FOUND, {}, nil]
end