Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use real assigns instead of a method call [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3591 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 35b74de7703515cf93da2d3e850702f58a2a6f48 1 parent 5f2292c
@dhh dhh authored
View
18 actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -671,10 +671,6 @@ def initialize(generator, root)
@generator = generator
@generator << root
end
-
- def assign(variable, value)
- append_to_function_chain! "#{variable} = #{@generator.send(:javascript_object_for, value)}"
- end
def replace_html(*options_for_render)
call 'update', @generator.render(*options_for_render)
@@ -685,12 +681,22 @@ def replace(*options_for_render)
end
private
+ def method_missing(method, *arguments)
+ if method.to_s =~ /(.*)=$/
+ assign($1, arguments.first)
+ else
+ call(method, *arguments)
+ end
+ end
+
def call(function, *arguments)
append_to_function_chain!("#{function}(#{@generator.send(:arguments_for_call, arguments)})")
self
end
-
- alias_method :method_missing, :call
+
+ def assign(variable, value)
+ append_to_function_chain! "#{variable} = #{@generator.send(:javascript_object_for, value)}"
+ end
def function_chain
@function_chain ||= @generator.instance_variable_get("@lines")
View
2  actionpack/test/template/prototype_helper_test.rb
@@ -238,7 +238,7 @@ def test_element_proxy_one_deep
end
def test_element_proxy_assignment
- @generator['hello'].assign :width, 400
+ @generator['hello'].width = 400
assert_equal %($('hello').width = 400;), @generator.to_s
end
Please sign in to comment.
Something went wrong with that request. Please try again.