aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-28 10:05:10 -0400
committerNeeraj Singh <neerajdotname@gmail.com>2010-07-28 10:05:10 -0400
commitff7e17d33e8042fa430fd637ef3433ef7367dc30 (patch)
tree733a0623469cc6ca54d53c13391f5545be354ac9 /activesupport/lib/active_support/core_ext/class
parentf3b50b11c7cba1ae21888c755cbeabf3b3aca072 (diff)
downloadrails-ff7e17d33e8042fa430fd637ef3433ef7367dc30.tar.gz
rails-ff7e17d33e8042fa430fd637ef3433ef7367dc30.tar.bz2
rails-ff7e17d33e8042fa430fd637ef3433ef7367dc30.zip
adding some comments to cattr_accessor method
Diffstat (limited to 'activesupport/lib/active_support/core_ext/class')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute_accessors.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
index feef5d2d57..cdc7cfc1d4 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
@@ -3,11 +3,17 @@ require 'active_support/core_ext/array/extract_options'
# 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!