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.



545
546
547
# File 'lib/action_dispatch/http/response.rb', line 545

def initialize(response)
  @response = response
end

Instance Attribute Details

#response ⇒ Object (readonly)

Returns the value of attribute response.



549
550
551
# File 'lib/action_dispatch/http/response.rb', line 549

def response
  @response
end

Instance Method Details

#body ⇒ Object



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

def body
  @response.body
end

#call(*arguments, &block) ⇒ Object



579
580
581
# File 'lib/action_dispatch/http/response.rb', line 579

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

#close ⇒ Object



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

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



575
576
577
# File 'lib/action_dispatch/http/response.rb', line 575

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

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

Returns:

  • (Boolean)


563
564
565
566
567
568
569
# File 'lib/action_dispatch/http/response.rb', line 563

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

#to_ary ⇒ Object



571
572
573
# File 'lib/action_dispatch/http/response.rb', line 571

def to_ary
  @response.stream.to_ary
end

#to_path ⇒ Object



583
584
585
# File 'lib/action_dispatch/http/response.rb', line 583

def to_path
  @response.stream.to_path
end