Class: ActionDispatch::Response::RackBody

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/http/response.rb

Constant Summary collapse

BODY_METHODS =
{ to_ary: true, each: true, call: true, to_path: true }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ RackBody

Returns a new instance of RackBody.



531
532
533
# File 'lib/action_dispatch/http/response.rb', line 531

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



535
536
537
# File 'lib/action_dispatch/http/response.rb', line 535

def response
  @response
end

Instance Method Details

#bodyObject



543
544
545
# File 'lib/action_dispatch/http/response.rb', line 543

def body
  @response.body
end

#call(*arguments, &block) ⇒ Object



565
566
567
# File 'lib/action_dispatch/http/response.rb', line 565

def call(*arguments, &block)
  @response.stream.call(*arguments, &block)
end

#closeObject



537
538
539
540
541
# File 'lib/action_dispatch/http/response.rb', line 537

def close
  # Rack "close" maps to Response#abort, and **not** Response#close (which is used
  # when the controller's finished writing)
  @response.abort
end

#each(*args, &block) ⇒ Object



561
562
563
# File 'lib/action_dispatch/http/response.rb', line 561

def each(*args, &block)
  @response.each(*args, &block)
end

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


549
550
551
552
553
554
555
# File 'lib/action_dispatch/http/response.rb', line 549

def respond_to?(method, include_private = false)
  if BODY_METHODS.key?(method)
    @response.stream.respond_to?(method)
  else
    super
  end
end

#to_aryObject



557
558
559
# File 'lib/action_dispatch/http/response.rb', line 557

def to_ary
  @response.stream.to_ary
end

#to_pathObject



569
570
571
# File 'lib/action_dispatch/http/response.rb', line 569

def to_path
  @response.stream.to_path
end