diff options
author | ayaya <ayaya@ayaya.tw> | 2012-01-31 18:43:54 +0800 |
---|---|---|
committer | ayaya <ayaya@ayaya.tw> | 2012-05-14 00:57:29 +0800 |
commit | c140a27fc55e294a130b874f075748c5cd03de1e (patch) | |
tree | e88ebb59e4f12c3e129c8452cb61bac9e0e32eab /activemodel/lib | |
parent | d98bbdee14384ff2e99e2f1716a8dff681521dea (diff) | |
download | rails-c140a27fc55e294a130b874f075748c5cd03de1e.tar.gz rails-c140a27fc55e294a130b874f075748c5cd03de1e.tar.bz2 rails-c140a27fc55e294a130b874f075748c5cd03de1e.zip |
fix `alias_attribute` will raise a syntax error if make an alias on a
column that named as a ruby keyword
Diffstat (limited to 'activemodel/lib')
-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 97a83e58af..dc4423d488 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -184,7 +184,7 @@ module ActiveModel attribute_method_matchers.each do |matcher| matcher_new = matcher.method_name(new_name).to_s matcher_old = matcher.method_name(old_name).to_s - define_optimized_call self, matcher_new, matcher_old + define_proxy_call false, self, matcher_new, matcher_old end end @@ -226,7 +226,7 @@ module ActiveModel if respond_to?(generate_method, true) send(generate_method, attr_name) else - define_optimized_call generated_attribute_methods, method_name, matcher.method_missing_target, attr_name.to_s + define_proxy_call true, generated_attribute_methods, method_name, matcher.method_missing_target, attr_name.to_s end end end @@ -285,7 +285,7 @@ module ActiveModel # Define a method `name` in `mod` that dispatches to `send` # using the given `extra` args. This fallbacks `define_method` # and `send` if the given names cannot be compiled. - def define_optimized_call(mod, name, send, *extra) #:nodoc: + def define_proxy_call(include_private, mod, name, send, *extra) #:nodoc: if name =~ NAME_COMPILABLE_REGEXP defn = "def #{name}(*args)" else @@ -295,7 +295,7 @@ module ActiveModel extra = (extra.map(&:inspect) << "*args").join(", ") if send =~ CALL_COMPILABLE_REGEXP - target = "#{send}(#{extra})" + target = "#{"self." unless include_private}#{send}(#{extra})" else target = "send(:'#{send}', #{extra})" end |