Change returning with tap

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Santiago Pastorino
2010-07-25 05:21:16 -03:00
committed by José Valim
parent 8d5b792e7d
commit b1cfcedc8f
6 changed files with 6 additions and 8 deletions

View File

@@ -365,7 +365,7 @@ module ActionController
def xml_http_request(request_method, action, parameters = nil, session = nil, flash = nil)
@request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
@request.env['HTTP_ACCEPT'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ')
returning __send__(request_method, action, parameters, session, flash) do
__send__(request_method, action, parameters, session, flash).tap do
@request.env.delete 'HTTP_X_REQUESTED_WITH'
@request.env.delete 'HTTP_ACCEPT'
end

View File

@@ -500,7 +500,7 @@ module ActionDispatch
end
def add_conditions_for(conditions, method)
returning({:conditions => conditions.dup}) do |options|
{:conditions => conditions.dup}.tap do |options|
options[:conditions][:method] = method unless method == :any
end
end

View File

@@ -319,7 +319,7 @@ module ActionDispatch
reset! unless @integration_session
# reset the html_document variable, but only for new get/post calls
@html_document = nil unless %w(cookies assigns).include?(method)
returning @integration_session.__send__(method, *args) do
@integration_session.__send__(method, *args).tap do
copy_session_variables!
end
end
@@ -362,7 +362,7 @@ module ActionDispatch
def method_missing(sym, *args, &block)
reset! unless @integration_session
if @integration_session.respond_to?(sym)
returning @integration_session.__send__(sym, *args, &block) do
@integration_session.__send__(sym, *args, &block).tap do
copy_session_variables!
end
else

View File

@@ -1,6 +1,5 @@
require 'cgi'
require 'action_view/helpers/tag_helper'
require 'active_support/core_ext/object/returning'
require 'active_support/core_ext/object/blank'
module ActionView
@@ -527,7 +526,7 @@ module ActionView
private
def html_options_for_form(url_for_options, options, *parameters_for_url)
returning options.stringify_keys do |html_options|
options.stringify_keys.tap do |html_options|
html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
# The following URL is unescaped, this is just a hash of options, and it is the
# responsability of the caller to escape all the values.

View File

@@ -114,7 +114,7 @@ class CaptureHelperTest < ActionView::TestCase
end
def view_with_controller
returning(TestController.new.view_context) do |view|
TestController.new.view_context.tap do |view|
view.output_buffer = ActionView::OutputBuffer.new
end
end

View File

@@ -1,5 +1,4 @@
require 'libxml'
require 'active_support/core_ext/object/returning'
require 'active_support/core_ext/object/blank'
# = XmlMini LibXML implementation