Class: HttpStub::Server::Stub::Response::File

Inherits:
Base
  • Object
show all
Defined in:
lib/http_stub/server/stub/response/file.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#delay_in_seconds, #headers, #status

Instance Method Summary collapse

Methods inherited from Base

add_default_headers, merge_defaults, #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

#uriObject (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(server) ⇒ Object



22
23
24
# File 'lib/http_stub/server/stub/response/file.rb', line 22

def serve_on(server)
  server.send_file(@file.path, send_options)
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