diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-07 11:28:03 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-07 11:28:15 -0500 |
commit | 17ef794299ae10c2a7b8ce7a2da68258267c9720 (patch) | |
tree | 894a847c2c9c0a15c93f91c88bfedc5cb8312f1b /activesupport/lib | |
parent | 700dd0014b8c19651650923dff28912e7d3607b9 (diff) | |
download | rails-17ef794299ae10c2a7b8ce7a2da68258267c9720.tar.gz rails-17ef794299ae10c2a7b8ce7a2da68258267c9720.tar.bz2 rails-17ef794299ae10c2a7b8ce7a2da68258267c9720.zip |
adding example about using cattr_accessor with subclasses
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/class/attribute_accessors.rb | 8 |
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. |