aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-07 11:28:03 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-07 11:28:15 -0500
commit17ef794299ae10c2a7b8ce7a2da68258267c9720 (patch)
tree894a847c2c9c0a15c93f91c88bfedc5cb8312f1b
parent700dd0014b8c19651650923dff28912e7d3607b9 (diff)
downloadrails-17ef794299ae10c2a7b8ce7a2da68258267c9720.tar.gz
rails-17ef794299ae10c2a7b8ce7a2da68258267c9720.tar.bz2
rails-17ef794299ae10c2a7b8ce7a2da68258267c9720.zip
adding example about using cattr_accessor with subclasses
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute_accessors.rb8
1 files changed, 8 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 5cb528cfe9..4f8866ce9d 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
@@ -15,6 +15,14 @@ require 'active_support/core_ext/array/extract_options'
# Person.hair_colors # => [:brown, :black, :blonde, :red]
# Person.new.hair_colors # => [:brown, :black, :blonde, :red]
#
+# class Female < Person
+# end
+#
+# Female.hair_colors << :pink
+# Female.hair_colors # => [:brown, :black, :blonde, :red, :pink]
+# Female.new.hair_colors # => [:brown, :black, :blonde, :red, :pink]
+# Person.hair_colors # => [:brown, :black, :blonde, :red, :pink]
+#
# To opt out of the instance writer method, pass :instance_writer => false.
# To opt out of the instance reader method, pass :instance_reader => false.
# To opt out of both instance methods, pass :instance_accessor => false.