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]
This commit is contained in:
Andrew White 2012-12-06 12:42:47 +00:00
parent 7b03d402ea
commit 8942035f42
1 changed files with 3 additions and 0 deletions

View File

@ -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