aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-28 10:13:11 -0400
committerNeeraj Singh <neerajdotname@gmail.com>2010-07-28 10:13:11 -0400
commit5b10e47593ed21fedba2401e3ad1f360e2cf0706 (patch)
treee8a7f48fdf5cd0c4dc863bcd9de0f1600416a065 /activesupport/lib
parenteb902d6c00f64e7060f24fa3b243d5b6dea98cac (diff)
downloadrails-5b10e47593ed21fedba2401e3ad1f360e2cf0706.tar.gz
rails-5b10e47593ed21fedba2401e3ad1f360e2cf0706.tar.bz2
rails-5b10e47593ed21fedba2401e3ad1f360e2cf0706.zip
adding comment specifying that cattr_accessor also supports instance_write and instance_rader option
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute_accessors.rb10
1 files changed, 10 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 cdc7cfc1d4..4e35b1b488 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
@@ -14,6 +14,16 @@ require 'active_support/core_ext/array/extract_options'
# Person.hair_colors = [:brown, :black, :blonde, :red]
# Person.hair_colors #=> [:brown, :black, :blonde, :red]
# Person.new.hair_colors #=> [:brown, :black, :blonde, :red]
+#
+# To opt out of the instance writer method, pass :instance_writer => false.
+# To opt out of the instance reader method, pass :instance_reader => false.
+#
+# class Person
+# cattr_accessor :hair_colors, :instance_writer => false, :instance_reader => false
+# end
+#
+# Person.new.hair_colors = [:brown] # => NoMethodError
+# Person.new.hair_colors # => NoMethodError
class Class
def cattr_reader(*syms)
options = syms.extract_options!