mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add documentation for class_attribute options
This commit is contained in:
parent
fb129373a3
commit
5fa6563f09
2 changed files with 11 additions and 2 deletions
|
@ -7,6 +7,16 @@ class Class
|
|||
# Declare a class-level attribute whose value is inheritable by subclasses.
|
||||
# Subclasses can change their own value and it will not impact parent class.
|
||||
#
|
||||
# ==== Options
|
||||
#
|
||||
# * <tt>:instance_reader</tt> - Sets the instance reader method (defaults to true).
|
||||
# * <tt>:instance_writer</tt> - Sets the instance writer method (defaults to true).
|
||||
# * <tt>:instance_accessor</tt> - Sets both instance methods (defaults to true).
|
||||
# * <tt>:instance_predicate</tt> - Sets a predicate method (defaults to true).
|
||||
# * <tt>:default</tt> - Sets a default value for the attribute (defaults to nil).
|
||||
#
|
||||
# ==== Examples
|
||||
#
|
||||
# class Base
|
||||
# class_attribute :setting
|
||||
# end
|
||||
|
|
|
@ -927,8 +927,7 @@ The generation of the writer instance method can be prevented by setting the opt
|
|||
```ruby
|
||||
module ActiveRecord
|
||||
class Base
|
||||
class_attribute :table_name_prefix, instance_writer: false
|
||||
self.table_name_prefix = ""
|
||||
class_attribute :table_name_prefix, instance_writer: false, default: "my"
|
||||
end
|
||||
end
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue