mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Clarify thread_mattr_accessor subclass behavior documentation
[ci skip]
This commit is contained in:
parent
ff85101730
commit
0c28a06495
1 changed files with 9 additions and 8 deletions
|
@ -96,22 +96,23 @@ class Module
|
||||||
|
|
||||||
# Defines both class and instance accessors for class attributes.
|
# Defines both class and instance accessors for class attributes.
|
||||||
#
|
#
|
||||||
# class Current
|
# class Account
|
||||||
# thread_mattr_accessor :user
|
# thread_mattr_accessor :user
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Current.user = "DHH"
|
# Account.user = "DHH"
|
||||||
# Current.user # => "DHH"
|
# Account.user # => "DHH"
|
||||||
# Current.new.user # => "DHH"
|
# Account.new.user # => "DHH"
|
||||||
#
|
#
|
||||||
# If a subclass changes the value then that will not change the value for
|
# If a subclass changes the value, the parent class' value is not changed.
|
||||||
# parent class. Similarly if parent class changes the value then that will not
|
# Similarly, if the parent class changes the value, the value of subclasses
|
||||||
# change the value of subclasses either.
|
# is not changed.
|
||||||
#
|
#
|
||||||
# class Customer < Account
|
# class Customer < Account
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Customer.user = "Rafael"
|
# Customer.user = "Rafael"
|
||||||
|
# Customer.user # => "Rafael"
|
||||||
# Account.user # => "DHH"
|
# Account.user # => "DHH"
|
||||||
#
|
#
|
||||||
# To opt out of the instance writer method, pass <tt>instance_writer: false</tt>.
|
# To opt out of the instance writer method, pass <tt>instance_writer: false</tt>.
|
||||||
|
|
Loading…
Reference in a new issue