diff options
author | Xavier Noria <fxn@hashref.com> | 2016-07-23 20:01:56 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-07-23 20:22:20 +0200 |
commit | 99cf7558000090668b137085bfe6bcc06c4571dc (patch) | |
tree | 33511db166bdbaa76ccd29a29daaf6bf343f149d /activerecord/lib/active_record/model_schema.rb | |
parent | 1ca571cc472ffea2dfab43ee57d8204e89d5b1a6 (diff) | |
download | rails-99cf7558000090668b137085bfe6bcc06c4571dc.tar.gz rails-99cf7558000090668b137085bfe6bcc06c4571dc.tar.bz2 rails-99cf7558000090668b137085bfe6bcc06c4571dc.zip |
systematic revision of =~ usage in AR
Where appropriatei, prefer the more concise Regexp#match?,
String#include?, String#start_with?, or String#end_with?
Diffstat (limited to 'activerecord/lib/active_record/model_schema.rb')
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 114686c5d3..99facb4b25 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -309,7 +309,12 @@ module ActiveRecord # Returns an array of column objects where the primary id, all columns ending in "_id" or "_count", # and columns used for single table inheritance have been removed. def content_columns - @content_columns ||= columns.reject { |c| c.name == primary_key || c.name =~ /(_id|_count)$/ || c.name == inheritance_column } + @content_columns ||= columns.reject do |c| + c.name == primary_key || + c.name == inheritance_column || + c.name.end_with?('_id') || + c.name.end_with?('_count') + end end # Resets all the cached information about columns, which will cause them |