Permalink
Browse files

adding some comments to cattr_accessor method

  • Loading branch information...
1 parent f3b50b1 commit ff7e17d33e8042fa430fd637ef3433ef7367dc30 Neeraj Singh committed Jul 28, 2010
Showing with 6 additions and 0 deletions.
  1. +6 −0 activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
@@ -3,11 +3,17 @@
# Extends the class object with class and instance accessors for class attributes,
# just like the native attr* accessors for instance attributes.
#
+# Note that unlike +class_attribute+, if a subclass changes the value then that would
+# also change the value for parent class. Similarly if parent class changes the value
+# then that would change the value of subclasses too.
+#
# class Person
# cattr_accessor :hair_colors
# end
#
# Person.hair_colors = [:brown, :black, :blonde, :red]
+# Person.hair_colors #=> [:brown, :black, :blonde, :red]
+# Person.new.hair_colors #=> [:brown, :black, :blonde, :red]
class Class
def cattr_reader(*syms)
options = syms.extract_options!

0 comments on commit ff7e17d

Please sign in to comment.