aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-12-06 12:42:47 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2012-12-06 12:45:25 +0000
commit8942035f428c1d89219aa7569869b53a42d9a610 (patch)
treeb4931dec8964d7efa6b432cfa2eba6ca9f20def2
parent7b03d402ea2759532264f4d4375dedd85e19ab1b (diff)
downloadrails-8942035f428c1d89219aa7569869b53a42d9a610.tar.gz
rails-8942035f428c1d89219aa7569869b53a42d9a610.tar.bz2
rails-8942035f428c1d89219aa7569869b53a42d9a610.zip
Add comment about implementation of class_attribute
To prevent future pull requests like #8435 add a comment about the implementation of class_attribute using class_eval for performance. [ci skip]
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index 1c3d26ead4..1504e18839 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -72,6 +72,9 @@ class Class
instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true)
+ # We use class_eval here rather than define_method because class_attribute
+ # may be used in a performance sensitive context therefore the overhead that
+ # define_method introduces may become significant.
attrs.each do |name|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def self.#{name}() nil end