aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-07 19:04:27 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-07 19:04:27 -0500
commit1ff35304885d86800d802748a053e0f4bef2ac91 (patch)
tree3f0e4d73ef06343315d6a3c45686717ada2e70a1 /activesupport
parent2fb6d12ad3a03c1d9b310fc6a01150f1af2af73b (diff)
downloadrails-1ff35304885d86800d802748a053e0f4bef2ac91.tar.gz
rails-1ff35304885d86800d802748a053e0f4bef2ac91.tar.bz2
rails-1ff35304885d86800d802748a053e0f4bef2ac91.zip
better docs for cattr_accessor and cattr_writer
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute_accessors.rb16
1 files changed, 14 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 7d85fd512c..4461cd6608 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
@@ -87,10 +87,12 @@ class Class
#
# Person.new.hair_colors = [:blonde, :red] # => NoMethodError
#
- # Also, you can pass a block to set up the variable with a default value.
+ # Also, you can pass a block to set up the attribute with a default value.
#
# class Person
- # cattr_writer(:hair_colors) {[:brown, :black, :blonde, :red]}
+ # cattr_writer :hair_colors do
+ # [:brown, :black, :blonde, :red]
+ # end
# end
#
# Person.class_variable_get("@@hair_colors") # => [:brown, :black, :blonde, :red]
@@ -157,6 +159,16 @@ class Class
#
# Person.new.hair_colors = [:brown] # => NoMethodError
# Person.new.hair_colors # => NoMethodError
+ #
+ # Also you can pass a block to set up the attribute with a default value.
+ #
+ # class Person
+ # cattr_accessor :hair_colors do
+ # [:brown, :black, :blonde, :red]
+ # end
+ # end
+ #
+ # Person.class_variable_get("@@hair_colors") #=> [:brown, :black, :blonde, :red]
def cattr_accessor(*syms, &blk)
cattr_reader(*syms)
cattr_writer(*syms, &blk)