From 5b10e47593ed21fedba2401e3ad1f360e2cf0706 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 10:13:11 -0400 Subject: adding comment specifying that cattr_accessor also supports instance_write and instance_rader option --- .../lib/active_support/core_ext/class/attribute_accessors.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') 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! -- cgit v1.2.3