From 17ef794299ae10c2a7b8ce7a2da68258267c9720 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 7 May 2012 11:28:03 -0500 Subject: adding example about using cattr_accessor with subclasses --- .../lib/active_support/core_ext/class/attribute_accessors.rb | 8 ++++++++ 1 file changed, 8 insertions(+) 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. -- cgit v1.2.3