Permalink
Browse files

LINE on class_eval need + 1, also removed comments [#4281 state:commi…

…tted]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent edbb952 commit 820e3a8491100ed24a6a33df07afee341956a45c @spastorino spastorino committed with josevalim Mar 27, 2010
View
51 activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
@@ -13,19 +13,20 @@ def cattr_reader(*syms)
options = syms.extract_options!
syms.each do |sym|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
- unless defined? @@#{sym} # unless defined? @@hair_colors
- @@#{sym} = nil # @@hair_colors = nil
- end # end
- #
- def self.#{sym} # def self.hair_colors
- @@#{sym} # @@hair_colors
- end # end
+ unless defined? @@#{sym}
+ @@#{sym} = nil
+ end
+
+ def self.#{sym}
+ @@#{sym}
+ end
EOS
+
unless options[:instance_reader] == false
- class_eval(<<-EOS, __FILE__, __LINE__)
- def #{sym} # def hair_colors
- @@#{sym} # @@hair_colors
- end # end
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{sym}
+ @@#{sym}
+ end
EOS
end
end
@@ -35,20 +36,22 @@ def cattr_writer(*syms)
options = syms.extract_options!
syms.each do |sym|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
- unless defined? @@#{sym} # unless defined? @@hair_colors
- @@#{sym} = nil # @@hair_colors = nil
- end # end
- #
- def self.#{sym}=(obj) # def self.hair_colors=(obj)
- @@#{sym} = obj # @@hair_colors = obj
- end # end
- #
- #{" #
- def #{sym}=(obj) # def hair_colors=(obj)
- @@#{sym} = obj # @@hair_colors = obj
- end # end
- " unless options[:instance_writer] == false } # # instance writer above is generated unless options[:instance_writer] == false
+ unless defined? @@#{sym}
+ @@#{sym} = nil
+ end
+
+ def self.#{sym}=(obj)
+ @@#{sym} = obj
+ end
EOS
+
+ unless options[:instance_writer] == false
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{sym}=(obj)
+ @@#{sym} = obj
+ end
+ EOS
+ end
self.send("#{sym}=", yield) if block_given?
end
end
View
40 activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
@@ -5,20 +5,20 @@ def mattr_reader(*syms)
options = syms.extract_options!
syms.each do |sym|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
- unless defined? @@#{sym} # unless defined? @@pagination_options
- @@#{sym} = nil # @@pagination_options = nil
- end # end
+ unless defined? @@#{sym}
+ @@#{sym} = nil
+ end
- def self.#{sym} # def self.pagination_options
- @@#{sym} # @@pagination_options
- end # end
+ def self.#{sym}
+ @@#{sym}
+ end
EOS
unless options[:instance_reader] == false
- class_eval(<<-EOS, __FILE__, __LINE__)
- def #{sym} # def hair_colors
- @@#{sym} # @@hair_colors
- end # end
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{sym}
+ @@#{sym}
+ end
EOS
end
end
@@ -28,20 +28,20 @@ def mattr_writer(*syms)
options = syms.extract_options!
syms.each do |sym|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
- unless defined? @@#{sym} # unless defined? @@pagination_options
- @@#{sym} = nil # @@pagination_options = nil
- end # end
+ unless defined? @@#{sym}
+ @@#{sym} = nil
+ end
- def self.#{sym}=(obj) # def self.pagination_options=(obj)
- @@#{sym} = obj # @@pagination_options = obj
- end # end
+ def self.#{sym}=(obj)
+ @@#{sym} = obj
+ end
EOS
unless options[:instance_writer] == false
- class_eval(<<-EOS, __FILE__, __LINE__)
- def #{sym}=(obj) # def pagination_options=(obj)
- @@#{sym} = obj # @@pagination_options = obj
- end # end
+ class_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{sym}=(obj)
+ @@#{sym} = obj
+ end
EOS
end
end

0 comments on commit 820e3a8

Please sign in to comment.