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.



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

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#bodyObject



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

def body
  @response.body
end

#call(*arguments, &block) ⇒ Object



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

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

#closeObject



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

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



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

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

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

Returns:

  • (Boolean)


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

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

#to_aryObject



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

def to_ary
  @response.stream.to_ary
end

#to_pathObject



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

def to_path
  @response.stream.to_path
end