diff options
author | Caleb Land <caleb.land@gmail.com> | 2011-02-03 13:46:03 -0500 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-03 19:05:17 -0200 |
commit | bca070ef2ddbbe7e093c340ec7722e4dca0f37a5 (patch) | |
tree | 529857731a61acb26081c599735d25243bdbb234 /activemodel/lib/active_model | |
parent | d65e3b481e72e8c76818a94353e9ac315c7c0272 (diff) | |
download | rails-bca070ef2ddbbe7e093c340ec7722e4dca0f37a5.tar.gz rails-bca070ef2ddbbe7e093c340ec7722e4dca0f37a5.tar.bz2 rails-bca070ef2ddbbe7e093c340ec7722e4dca0f37a5.zip |
allow spaces and other characters in attribute names [#4725 state:resolved]
* define the dynamically defined methods with
'define_method' instead of def
* wrap some string injected method names in quotes
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/attribute_methods.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 34669c1542..f46fa3a5e2 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -230,8 +230,8 @@ module ActiveModel def alias_attribute(new_name, old_name) attribute_method_matchers.each do |matcher| module_eval <<-STR, __FILE__, __LINE__ + 1 - def #{matcher.method_name(new_name)}(*args) - send(:#{matcher.method_name(old_name)}, *args) + define_method(:'#{matcher.method_name(new_name)}') do |*args| + send(:'#{matcher.method_name(old_name)}', *args) end STR end @@ -277,8 +277,8 @@ module ActiveModel if method_defined?(:'#{method_name}') undef :'#{method_name}' end - def #{method_name}(*args) - send(:#{matcher.method_missing_target}, '#{attr_name}', *args) + define_method(:'#{method_name}') do |*args| + send(:'#{matcher.method_missing_target}', '#{attr_name}', *args) end STR end |