Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use #remove_possible_method instead #387

Merged
merged 2 commits into from

2 participants

@smartinez87

use remove_possible_method in favor of remove_method if method_defined?

@josevalim
Owner

Cool. I think there are other places in actionpack that could be changed as well.

@smartinez87

Yes, changing them all and will update the pull request.

@josevalim josevalim merged commit 871096d into rails:master
@josevalim
Owner

Please send a new pull request then. This one was already applied. :D

@smartinez87

here is the pull request for the other places I found it:
#388

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
5 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -3,6 +3,7 @@
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/hash/slice'
+require 'active_support/core_ext/module/remove_method'
module ActionDispatch
module Routing
@@ -160,7 +161,7 @@ def define_hash_access(route, name, kind, options)
# We use module_eval to avoid leaks
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
- remove_method :#{selector} if method_defined?(:#{selector})
+ remove_possible_method :#{selector}
def #{selector}(*args)
options = args.extract_options!
@@ -194,7 +195,7 @@ def define_url_helper(route, name, kind, options)
hash_access_method = hash_access_name(name, kind)
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
- remove_method :#{selector} if method_defined?(:#{selector})
+ remove_possible_method :#{selector}
def #{selector}(*args)
url_for(#{hash_access_method}(*args))
end
View
2  activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -84,7 +84,7 @@ def #{name}
val
end
- remove_method :#{name} if method_defined?(:#{name})
+ remove_possible_method :#{name}
def #{name}
defined?(@#{name}) ? @#{name} : self.class.#{name}
end
Something went wrong with that request. Please try again.