diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2011-06-13 18:47:10 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-06-13 18:56:06 +0200 |
commit | b12c2e4ebb85170467ac250219557d631c842d8d (patch) | |
tree | c00f317cd91c3f4631e7471b4de6d1e7c94f68d9 /activesupport/lib | |
parent | 276618c6526587231cdcb783cc104e89e6458c56 (diff) | |
download | rails-b12c2e4ebb85170467ac250219557d631c842d8d.tar.gz rails-b12c2e4ebb85170467ac250219557d631c842d8d.tar.bz2 rails-b12c2e4ebb85170467ac250219557d631c842d8d.zip |
Added instance_accessor: false as an option to Class#cattr_accessor and friends [DHH]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/class/attribute_accessors.rb | 5 |
1 files changed, 3 insertions, 2 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 a903735acf..268303aaf2 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb @@ -17,6 +17,7 @@ require 'active_support/core_ext/array/extract_options' # # 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. # # class Person # cattr_accessor :hair_colors, :instance_writer => false, :instance_reader => false @@ -38,7 +39,7 @@ class Class end EOS - unless options[:instance_reader] == false + unless options[:instance_reader] == false || options[:instance_accessor] == false class_eval(<<-EOS, __FILE__, __LINE__ + 1) def #{sym} @@#{sym} @@ -61,7 +62,7 @@ class Class end EOS - unless options[:instance_writer] == false + unless options[:instance_writer] == false || options[:instance_accessor] == false class_eval(<<-EOS, __FILE__, __LINE__ + 1) def #{sym}=(obj) @@#{sym} = obj |