Class: Gitlab::FileResponse
- Inherits:
-
Object
- Object
- Gitlab::FileResponse
show all
- Defined in:
- lib/gitlab/file_response.rb
Constant Summary
collapse
'content-disposition'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of FileResponse.
9
10
11
|
# File 'lib/gitlab/file_response.rb', line 9
def initialize(file)
@file = file
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/gitlab/file_response.rb', line 26
def method_missing(name, *, &)
if @file.respond_to?(name)
@file.send(name, *, &)
else
super
end
end
|
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
7
8
9
|
# File 'lib/gitlab/file_response.rb', line 7
def filename
@filename
end
|
Instance Method Details
#empty? ⇒ Boolean
13
14
15
|
# File 'lib/gitlab/file_response.rb', line 13
def empty?
false
end
|
#inspect ⇒ Object
22
23
24
|
# File 'lib/gitlab/file_response.rb', line 22
def inspect
"#<#{self.class}:#{object_id} {filename: #{filename.inspect}}>"
end
|
38
39
40
41
|
# File 'lib/gitlab/file_response.rb', line 38
def ()
@filename = [HEADER_CONTENT_DISPOSITION].split('filename=')[1]
@filename = @filename[1...-1] if @filename[0] == '"'
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
34
35
36
|
# File 'lib/gitlab/file_response.rb', line 34
def respond_to_missing?(method_name, include_private = false)
super || @file.respond_to?(method_name, include_private)
end
|
#to_hash ⇒ Object
Also known as:
to_h
17
18
19
|
# File 'lib/gitlab/file_response.rb', line 17
def to_hash
{ filename: @filename, data: @file }
end
|