Skip to content

Commit

Permalink
LINE on class_eval need + 1, also removed comments [#4281 state:commi…
Browse files Browse the repository at this point in the history
…tted]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
spastorino authored and josevalim committed Mar 27, 2010
1 parent edbb952 commit 820e3a8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
Expand Up @@ -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
Expand All @@ -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
Expand Down
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 820e3a8

Please sign in to comment.