Class: HttpStub::Server::Stub::Response::File
- Defined in:
- lib/http_stub/server/stub/response/file.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Attributes inherited from Base
#delay_in_seconds, #headers, #status
Instance Method Summary collapse
-
#initialize(args) ⇒ File
constructor
A new instance of File.
- #serve_on(application) ⇒ Object
- #to_hash ⇒ Object
- #with_values_from(request) ⇒ Object
Methods inherited from Base
add_default_headers, merge_defaults, #to_json, #type
Constructor Details
#initialize(args) ⇒ File
Returns a new instance of File.
12 13 14 15 16 |
# File 'lib/http_stub/server/stub/response/file.rb', line 12 def initialize(args) @file = args["body"][:tempfile] @uri = "file://#{@file.path}" super end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
10 11 12 |
# File 'lib/http_stub/server/stub/response/file.rb', line 10 def uri @uri end |
Instance Method Details
#serve_on(application) ⇒ Object
22 23 24 25 |
# File 'lib/http_stub/server/stub/response/file.rb', line 22 def serve_on(application) application.send_file(@file.path, ) @status = application.response.status end |
#to_hash ⇒ Object
27 28 29 |
# File 'lib/http_stub/server/stub/response/file.rb', line 27 def to_hash super.merge(file_uri: @uri) end |
#with_values_from(request) ⇒ Object
18 19 20 |
# File 'lib/http_stub/server/stub/response/file.rb', line 18 def with_values_from(request) self.class.new(@original_args.merge("headers" => @headers.with_values_from(request))) end |