aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2011-06-13 18:47:10 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2011-06-13 18:56:06 +0200
commitb12c2e4ebb85170467ac250219557d631c842d8d (patch)
treec00f317cd91c3f4631e7471b4de6d1e7c94f68d9 /activesupport/lib/active_support/core_ext/class
parent276618c6526587231cdcb783cc104e89e6458c56 (diff)
downloadrails-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/active_support/core_ext/class')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute_accessors.rb5
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