1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add mention about ActiveRecord::Base::filter_attributes to the changelog entry

Also remove `# :nodoc:` for `ActiveRecord::Core::ClassMethods` in order
to show non-nodoc methods in that module on the api docs http://edgeapi.rubyonrails.org
This commit is contained in:
bogdanvlviv 2018-09-10 19:10:44 +03:00
parent d1a14865e0
commit 59cae0755e
No known key found for this signature in database
GPG key ID: E4ACD76A6DB6DFDD
2 changed files with 13 additions and 8 deletions

View file

@ -9,11 +9,16 @@
*Darwin Wu*
* Configuration item `config.filter_parameters` could also filter out sensitive value of database column when call `#inspect`.
* Configuration item `config.filter_parameters` could also filter out
sensitive values of database columns when call `#inspect`.
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
specify sensitive attributes to specific model.
```
Rails.application.config.filter_parameters += [:credit_card_number]
Account.last.inspect # => #<Account id: 123, credit_card_number: [FILTERED] ...>
Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED] ...>
SecureAccount.filter_attributes += [:name]
SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
```
*Zhang Kang*

View file

@ -139,7 +139,7 @@ module ActiveRecord
self.default_connection_handler = ConnectionAdapters::ConnectionHandler.new
end
module ClassMethods # :nodoc:
module ClassMethods
def initialize_find_by_cache # :nodoc:
@find_by_statement_cache = { true => Concurrent::Map.new, false => Concurrent::Map.new }
end
@ -216,7 +216,7 @@ module ActiveRecord
generated_association_methods
end
def generated_association_methods
def generated_association_methods # :nodoc:
@generated_association_methods ||= begin
mod = const_set(:GeneratedAssociationMethods, Module.new)
private_constant :GeneratedAssociationMethods
@ -226,7 +226,7 @@ module ActiveRecord
end
end
# Returns columns which shouldn't be exposed while calling #inspect.
# Returns columns which shouldn't be exposed while calling +#inspect+.
def filter_attributes
if defined?(@filter_attributes)
@filter_attributes
@ -235,13 +235,13 @@ module ActiveRecord
end
end
# Specifies columns which shouldn't be exposed while calling #inspect.
# Specifies columns which shouldn't be exposed while calling +#inspect+.
def filter_attributes=(attributes_names)
@filter_attributes = attributes_names.map(&:to_s).to_set
end
# Returns a string like 'Post(id:integer, title:string, body:text)'
def inspect
def inspect # :nodoc:
if self == Base
super
elsif abstract_class?
@ -257,7 +257,7 @@ module ActiveRecord
end
# Overwrite the default class equality method to provide support for decorated models.
def ===(object)
def ===(object) # :nodoc:
object.is_a?(self)
end