mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
adding some comments to cattr_accessor method
This commit is contained in:
@@ -3,11 +3,17 @@ require 'active_support/core_ext/array/extract_options'
|
||||
# Extends the class object with class and instance accessors for class attributes,
|
||||
# just like the native attr* accessors for instance attributes.
|
||||
#
|
||||
# Note that unlike +class_attribute+, if a subclass changes the value then that would
|
||||
# also change the value for parent class. Similarly if parent class changes the value
|
||||
# then that would change the value of subclasses too.
|
||||
#
|
||||
# class Person
|
||||
# cattr_accessor :hair_colors
|
||||
# end
|
||||
#
|
||||
# Person.hair_colors = [:brown, :black, :blonde, :red]
|
||||
# Person.hair_colors #=> [:brown, :black, :blonde, :red]
|
||||
# Person.new.hair_colors #=> [:brown, :black, :blonde, :red]
|
||||
class Class
|
||||
def cattr_reader(*syms)
|
||||
options = syms.extract_options!
|
||||
|
||||
Reference in New Issue
Block a user