Created
July 21, 2010 09:36
-
-
Save Panmind/484271 to your computer and use it in GitHub Desktop.
You already know: obtrusive Javascript is evil and clumsy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Because obtrusive JavaScript is evil, and the Joe developer must not | |
# be able to introduce it with an "innocent" :method => :delete option | |
# passed to a link_to. | |
# (C) 2010 Panmind - Released in the Public Domain | |
# | |
helper = ActionView::Helpers::JavaScriptHelper | |
keep = %w(javascript_tag javascript_cdata_section escape_javascript) | |
keep.map!(&:to_sym) if RUBY_VERSION.to_f >= 1.9 | |
methods = helper.public_instance_methods - keep | |
helper.class_eval do | |
methods.each do |meth| | |
undef_method meth | |
define_method(meth) do |*args| | |
raise NotImplementedError, 'This method is not available in this application' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment