Class: HttpStub::Server::Stub::Response::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/http_stub/server/stub/response/text.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, #to_json, #type

Constructor Details

#initialize(args = {}) ⇒ Text

Returns a new instance of Text.



12
13
14
15
# File 'lib/http_stub/server/stub/response/text.rb', line 12

def initialize(args={})
  super
  @body = HttpStub::Server::Stub::Response::Attribute::Body.new(args["body"])
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/http_stub/server/stub/response/text.rb', line 10

def body
  @body
end

Instance Method Details

#serve_on(application) ⇒ Object



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

def serve_on(application)
  application.halt(@status, @headers.to_hash, @body)
end

#to_hashObject



26
27
28
# File 'lib/http_stub/server/stub/response/text.rb', line 26

def to_hash
  super.merge(body: @body)
end

#with_values_from(request) ⇒ Object



17
18
19
20
# File 'lib/http_stub/server/stub/response/text.rb', line 17

def with_values_from(request)
  self.class.new(@original_args.merge("headers" => @headers.with_values_from(request),
                                      "body"    => @body.with_values_from(request)))
end