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 Method Summary collapse

Constructor Details

#initialize(response) ⇒ RackBody

Returns a new instance of RackBody.



498
499
500
# File 'lib/action_dispatch/http/response.rb', line 498

def initialize(response)
  @response = response
end

Instance Method Details

#bodyObject



508
509
510
# File 'lib/action_dispatch/http/response.rb', line 508

def body
  @response.body
end

#call(*arguments, &block) ⇒ Object



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

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

#closeObject



502
503
504
505
506
# File 'lib/action_dispatch/http/response.rb', line 502

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



526
527
528
# File 'lib/action_dispatch/http/response.rb', line 526

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

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

Returns:

  • (Boolean)


514
515
516
517
518
519
520
# File 'lib/action_dispatch/http/response.rb', line 514

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

#to_aryObject



522
523
524
# File 'lib/action_dispatch/http/response.rb', line 522

def to_ary
  @response.stream.to_ary
end

#to_pathObject



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

def to_path
  @response.stream.to_path
end