Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get rid of 'Object#send!'. It was originally added because it's in Ru…
…by 1.9, but it has since been removed from 1.9.

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>

Conflicts:

	actionpack/test/controller/layout_test.rb
  • Loading branch information
jeremy committed Aug 31, 2008
1 parent e9a8e00 commit a1eb4e1
Show file tree
Hide file tree
Showing 35 changed files with 86 additions and 92 deletions.
4 changes: 2 additions & 2 deletions actionmailer/lib/action_mailer/helpers.rb
Expand Up @@ -72,7 +72,7 @@ def helper_method(*methods)
methods.flatten.each do |method|
master_helper_module.module_eval <<-end_eval
def #{method}(*args, &block)
controller.send!(%(#{method}), *args, &block)
controller.__send__(%(#{method}), *args, &block)
end
end_eval
end
Expand All @@ -92,7 +92,7 @@ def inherited_with_helper(child)
inherited_without_helper(child)
begin
child.master_helper_module = Module.new
child.master_helper_module.send! :include, master_helper_module
child.master_helper_module.__send__(:include, master_helper_module)
child.helper child.name.to_s.underscore
rescue MissingSourceFile => e
raise unless e.is_missing?("helpers/#{child.name.to_s.underscore}_helper")
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/caching/actions.rb
Expand Up @@ -90,7 +90,7 @@ def before(controller)
set_content_type!(controller, cache_path.extension)
options = { :text => cache }
options.merge!(:layout => true) if cache_layout?
controller.send!(:render, options)
controller.__send__(:render, options)
false
else
controller.action_cache_path = cache_path
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/caching/sweeping.rb
Expand Up @@ -83,13 +83,13 @@ def callback(timing)
controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"

send!(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
send!(action_callback_method_name) if respond_to?(action_callback_method_name, true)
__send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
__send__(action_callback_method_name) if respond_to?(action_callback_method_name, true)
end

def method_missing(method, *arguments)
return if @controller.nil?
@controller.send!(method, *arguments)
@controller.__send__(method, *arguments)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/cgi_process.rb
Expand Up @@ -48,7 +48,7 @@ class SessionFixationAttempt < StandardError #:nodoc:
def initialize(cgi, session_options = {})
@cgi = cgi
@session_options = session_options
@env = @cgi.send!(:env_table)
@env = @cgi.__send__(:env_table)
super()
end

Expand Down Expand Up @@ -107,7 +107,7 @@ def reset_session
end

def method_missing(method_id, *arguments)
@cgi.send!(method_id, *arguments) rescue super
@cgi.__send__(method_id, *arguments) rescue super
end

private
Expand Down Expand Up @@ -164,7 +164,7 @@ def out(output = $stdout)
begin
output.write(@cgi.header(@headers))

if @cgi.send!(:env_table)['REQUEST_METHOD'] == 'HEAD'
if @cgi.__send__(:env_table)['REQUEST_METHOD'] == 'HEAD'
return
elsif @body.respond_to?(:call)
# Flush the output now in case the @body Proc uses
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/components.rb
Expand Up @@ -65,7 +65,7 @@ def process_with_components(request, response, parent_controller = nil) #:nodoc:

module HelperMethods
def render_component(options)
@controller.send!(:render_component_as_string, options)
@controller.__send__(:render_component_as_string, options)
end
end

Expand Down
8 changes: 4 additions & 4 deletions actionpack/lib/action_controller/filters.rb
Expand Up @@ -199,8 +199,8 @@ def around_proc
Proc.new do |controller, action|
method.before(controller)

if controller.send!(:performed?)
controller.send!(:halt_filter_chain, method, :rendered_or_redirected)
if controller.__send__(:performed?)
controller.__send__(:halt_filter_chain, method, :rendered_or_redirected)
else
begin
action.call
Expand All @@ -223,8 +223,8 @@ def before?

def call(controller, &block)
super
if controller.send!(:performed?)
controller.send!(:halt_filter_chain, method, :rendered_or_redirected)
if controller.__send__(:performed?)
controller.__send__(:halt_filter_chain, method, :rendered_or_redirected)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/helpers.rb
Expand Up @@ -204,8 +204,8 @@ def inherited_with_helper(child)

begin
child.master_helper_module = Module.new
child.master_helper_module.send! :include, master_helper_module
child.send! :default_helper_module!
child.master_helper_module.__send__ :include, master_helper_module
child.__send__ :default_helper_module!
rescue MissingSourceFile => e
raise unless e.is_missing?("helpers/#{child.controller_path}_helper")
end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/http_authentication.rb
Expand Up @@ -117,7 +117,7 @@ def encode_credentials(user_name, password)

def authentication_request(controller, realm)
controller.headers["WWW-Authenticate"] = %(Basic realm="#{realm.gsub(/"/, "")}")
controller.send! :render, :text => "HTTP Basic: Access denied.\n", :status => :unauthorized
controller.__send__ :render, :text => "HTTP Basic: Access denied.\n", :status => :unauthorized
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions actionpack/lib/action_controller/integration.rb
Expand Up @@ -444,7 +444,7 @@ def reset!
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
returning @integration_session.__send__(method, *args) do
copy_session_variables!
end
end
Expand All @@ -469,12 +469,12 @@ def open_session
self.class.fixture_table_names.each do |table_name|
name = table_name.tr(".", "_")
next unless respond_to?(name)
extras.send!(:define_method, name) { |*args| delegate.send(name, *args) }
extras.__send__(:define_method, name) { |*args| delegate.send(name, *args) }
end
end

# delegate add_assertion to the test case
extras.send!(:define_method, :add_assertion) { test_result.add_assertion }
extras.__send__(:define_method, :add_assertion) { test_result.add_assertion }
session.extend(extras)
session.delegate = self
session.test_result = @_result
Expand All @@ -488,7 +488,7 @@ def open_session
def copy_session_variables! #:nodoc:
return unless @integration_session
%w(controller response request).each do |var|
instance_variable_set("@#{var}", @integration_session.send!(var))
instance_variable_set("@#{var}", @integration_session.__send__(var))
end
end

Expand Down
8 changes: 4 additions & 4 deletions actionpack/lib/action_controller/layout.rb
Expand Up @@ -219,7 +219,7 @@ def active_layout(passed_layout = nil)
layout = passed_layout || self.class.default_layout(default_template_format)
active_layout = case layout
when String then layout
when Symbol then send!(layout)
when Symbol then __send__(layout)
when Proc then layout.call(self)
end

Expand All @@ -238,7 +238,7 @@ def active_layout(passed_layout = nil)
private
def candidate_for_layout?(options)
options.values_at(:text, :xml, :json, :file, :inline, :partial, :nothing, :update).compact.empty? &&
!@template.send(:_exempt_from_layout?, options[:template] || default_template_name(options[:action]))
!@template.__send__(:_exempt_from_layout?, options[:template] || default_template_name(options[:action]))
end

def pick_layout(options)
Expand All @@ -247,7 +247,7 @@ def pick_layout(options)
when FalseClass
nil
when NilClass, TrueClass
active_layout if action_has_layout? && !@template.send(:_exempt_from_layout?, default_template_name)
active_layout if action_has_layout? && !@template.__send__(:_exempt_from_layout?, default_template_name)
else
active_layout(layout)
end
Expand All @@ -272,7 +272,7 @@ def action_has_layout?
end

def layout_directory?(layout_name)
@template.send(:_pick_template, "#{File.join('layouts', layout_name)}.#{@template.template_format}") ? true : false
@template.__send__(:_pick_template, "#{File.join('layouts', layout_name)}.#{@template.template_format}") ? true : false
rescue ActionView::MissingTemplate
false
end
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/polymorphic_routes.rb
Expand Up @@ -108,7 +108,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
args.last.kind_of?(Hash) ? args.last.merge!(url_options) : args << url_options
end

send!(named_route, *args)
__send__(named_route, *args)
end

# Returns the path component of a URL for the given record. It uses
Expand Down Expand Up @@ -149,15 +149,15 @@ def build_named_route_call(records, namespace, inflection, options = {})
if parent.is_a?(Symbol) || parent.is_a?(String)
string << "#{parent}_"
else
string << "#{RecordIdentifier.send!("singular_class_name", parent)}_"
string << "#{RecordIdentifier.__send__("singular_class_name", parent)}_"
end
end
end

if record.is_a?(Symbol) || record.is_a?(String)
route << "#{record}_"
else
route << "#{RecordIdentifier.send!("#{inflection}_class_name", record)}_"
route << "#{RecordIdentifier.__send__("#{inflection}_class_name", record)}_"
end

action_prefix(options) + namespace + route + routing_type(options).to_s
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/routing/route_set.rb
Expand Up @@ -115,7 +115,7 @@ def reset!
def install(destinations = [ActionController::Base, ActionView::Base], regenerate = false)
reset! if regenerate
Array(destinations).each do |dest|
dest.send! :include, @module
dest.__send__(:include, @module)
end
end

Expand Down Expand Up @@ -353,15 +353,15 @@ def generate(options, recall = {}, method=:generate)
if generate_all
# Used by caching to expire all paths for a resource
return routes.collect do |route|
route.send!(method, options, merged, expire_on)
route.__send__(method, options, merged, expire_on)
end.compact
end

# don't use the recalled keys when determining which routes to check
routes = routes_by_controller[controller][action][options.keys.sort_by { |x| x.object_id }]

routes.each do |route|
results = route.send!(method, options, merged, expire_on)
results = route.__send__(method, options, merged, expire_on)
return results if results && (!results.is_a?(Array) || results.first)
end
end
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/test_process.rb
Expand Up @@ -357,7 +357,7 @@ def path #:nodoc:
alias local_path path

def method_missing(method_name, *args, &block) #:nodoc:
@tempfile.send!(method_name, *args, &block)
@tempfile.__send__(method_name, *args, &block)
end
end

Expand Down Expand Up @@ -403,7 +403,7 @@ def process(action, parameters = nil, session = nil, flash = nil)
def xml_http_request(request_method, action, parameters = nil, session = nil, flash = nil)
@request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
@request.env['HTTP_ACCEPT'] = 'text/javascript, text/html, application/xml, text/xml, */*'
returning send!(request_method, action, parameters, session, flash) do
returning __send__(request_method, action, parameters, session, flash) do
@request.env.delete 'HTTP_X_REQUESTED_WITH'
@request.env.delete 'HTTP_ACCEPT'
end
Expand Down Expand Up @@ -436,7 +436,7 @@ def redirect_to_url

def build_request_uri(action, parameters)
unless @request.env['REQUEST_URI']
options = @controller.send!(:rewrite_options, parameters)
options = @controller.__send__(:rewrite_options, parameters)
options.update(:only_path => true, :action => action)

url = ActionController::UrlRewriter.new(@request, parameters)
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/verification.rb
Expand Up @@ -80,7 +80,7 @@ module ClassMethods
# array (may also be a single value).
def verify(options={})
before_filter :only => options[:only], :except => options[:except] do |c|
c.send! :verify_action, options
c.__send__ :verify_action, options
end
end
end
Expand Down Expand Up @@ -116,7 +116,7 @@ def verify_request_xhr_status(options) # :nodoc:
end

def apply_redirect_to(redirect_to_option) # :nodoc:
(redirect_to_option.is_a?(Symbol) && redirect_to_option != :back) ? self.send!(redirect_to_option) : redirect_to_option
(redirect_to_option.is_a?(Symbol) && redirect_to_option != :back) ? self.__send__(redirect_to_option) : redirect_to_option
end

def apply_remaining_actions(options) # :nodoc:
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/test_case.rb
Expand Up @@ -54,7 +54,7 @@ def initialize
private
def method_missing(selector, *args)
controller = TestController.new
return controller.send!(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
return controller.__send__(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
super
end
end
Expand Down
8 changes: 4 additions & 4 deletions actionpack/test/controller/base_test.rb
Expand Up @@ -84,11 +84,11 @@ def setup
def test_action_methods
@empty_controllers.each do |c|
hide_mocha_methods_from_controller(c)
assert_equal Set.new, c.send!(:action_methods), "#{c.controller_path} should be empty!"
assert_equal Set.new, c.__send__(:action_methods), "#{c.controller_path} should be empty!"
end
@non_empty_controllers.each do |c|
hide_mocha_methods_from_controller(c)
assert_equal Set.new(%w(public_action)), c.send!(:action_methods), "#{c.controller_path} should not be empty!"
assert_equal Set.new(%w(public_action)), c.__send__(:action_methods), "#{c.controller_path} should not be empty!"
end
end

Expand All @@ -100,7 +100,7 @@ def hide_mocha_methods_from_controller(controller)
:expects, :mocha, :mocha_inspect, :reset_mocha, :stubba_object,
:stubba_method, :stubs, :verify, :__metaclass__, :__is_a__, :to_matcher,
]
controller.class.send!(:hide_action, *mocha_methods)
controller.class.__send__(:hide_action, *mocha_methods)
end
end

Expand Down Expand Up @@ -140,7 +140,7 @@ def test_get_on_priv_should_show_selector

def test_method_missing_is_not_an_action_name
use_controller MethodMissingController
assert ! @controller.send!(:action_methods).include?('method_missing')
assert ! @controller.__send__(:action_methods).include?('method_missing')

get :method_missing
assert_response :success
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/controller/filter_params_test.rb
Expand Up @@ -27,7 +27,7 @@ def test_filter_parameters

test_hashes.each do |before_filter, after_filter, filter_words|
FilterParamController.filter_parameter_logging(*filter_words)
assert_equal after_filter, @controller.send!(:filter_parameters, before_filter)
assert_equal after_filter, @controller.__send__(:filter_parameters, before_filter)

filter_words.push('blah')
FilterParamController.filter_parameter_logging(*filter_words) do |key, value|
Expand All @@ -37,7 +37,7 @@ def test_filter_parameters
before_filter['barg'] = {'bargain'=>'gain', 'blah'=>'bar', 'bar'=>{'bargain'=>{'blah'=>'foo'}}}
after_filter['barg'] = {'bargain'=>'niag', 'blah'=>'[FILTERED]', 'bar'=>{'bargain'=>{'blah'=>'[FILTERED]'}}}

assert_equal after_filter, @controller.send!(:filter_parameters, before_filter)
assert_equal after_filter, @controller.__send__(:filter_parameters, before_filter)
end
end

Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/filters_test.rb
Expand Up @@ -364,7 +364,7 @@ def filter(controller)
begin
yield
rescue ErrorToRescue => ex
controller.send! :render, :text => "I rescued this: #{ex.inspect}"
controller.__send__ :render, :text => "I rescued this: #{ex.inspect}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/integration_test.rb
Expand Up @@ -243,7 +243,7 @@ def test_integration_methods_called
reset!
stub_integration_session(@integration_session)
%w( get post head put delete ).each do |verb|
assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') }
assert_nothing_raised("'#{verb}' should use integration test methods") { __send__(verb, '/') }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/validations.rb
Expand Up @@ -4,7 +4,7 @@ module ActiveModel
module Validations
def self.included(base) # :nodoc:
base.extend(ClassMethods)
base.send!(:include, ActiveSupport::Callbacks)
base.__send__(:include, ActiveSupport::Callbacks)
base.define_callbacks :validate, :validate_on_create, :validate_on_update
end

Expand Down
2 changes: 1 addition & 1 deletion activeresource/lib/active_resource/base.rb
Expand Up @@ -1012,7 +1012,7 @@ def find_or_create_resource_for(name)
end

def split_options(options = {})
self.class.send!(:split_options, options)
self.class.__send__(:split_options, options)
end

def method_missing(method_symbol, *arguments) #:nodoc:
Expand Down
4 changes: 2 additions & 2 deletions activeresource/lib/active_resource/custom_methods.rb
Expand Up @@ -109,11 +109,11 @@ def delete(method_name, options = {})

private
def custom_method_element_url(method_name, options = {})
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.#{self.class.format.extension}#{self.class.send!(:query_string, options)}"
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}"
end

def custom_method_new_element_url(method_name, options = {})
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.#{self.class.format.extension}#{self.class.send!(:query_string, options)}"
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}"
end
end
end
Expand Down

1 comment on commit a1eb4e1

@smtlaissezfaire
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren’t these instances converted to instance_eval { … } ? 1.9 Is still only allowing public calls through send, correct?

Please sign in to comment.