Class: Shrine::Plugins::RackResponse::FileResponse
- Inherits:
-
Object
- Object
- Shrine::Plugins::RackResponse::FileResponse
- Defined in:
- lib/shrine/plugins/rack_response.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#call(**options) ⇒ Object
Returns a Rack response triple for the uploaded file.
-
#initialize(file) ⇒ FileResponse
constructor
A new instance of FileResponse.
Constructor Details
#initialize(file) ⇒ FileResponse
Returns a new instance of FileResponse.
23 24 25 |
# File 'lib/shrine/plugins/rack_response.rb', line 23 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
21 22 23 |
# File 'lib/shrine/plugins/rack_response.rb', line 21 def file @file end |
Instance Method Details
#call(**options) ⇒ Object
Returns a Rack response triple for the uploaded file.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/shrine/plugins/rack_response.rb', line 28 def call(**) file.open unless file.opened? [:range] = parse_content_range([:range]) if [:range] status = rack_status(**) headers = rack_headers(**) body = rack_body(**) [status, headers, body] end |