diff options
author | Akira Matsuda <ronnie@dio.jp> | 2016-12-23 15:51:11 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2016-12-24 23:39:36 +0900 |
commit | 5b14129d8d4ad302b4e11df6bd5c7891b75f393c (patch) | |
tree | cfcd0a51846f540f40cc314e29a7070b415a9219 /activerecord/lib/rails | |
parent | 6c5bbb4b7d3bdd1b43e512fb6ae764c373c7827b (diff) | |
download | rails-5b14129d8d4ad302b4e11df6bd5c7891b75f393c.tar.gz rails-5b14129d8d4ad302b4e11df6bd5c7891b75f393c.tar.bz2 rails-5b14129d8d4ad302b4e11df6bd5c7891b75f393c.zip |
Privatize unneededly protected methods in Active Record
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/migration/migration_generator.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/model_generator.rb | 12 |
2 files changed, 11 insertions, 10 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb index ec2d355b6e..1de2aff632 100644 --- a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb +++ b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb @@ -18,10 +18,12 @@ module ActiveRecord protected attr_reader :migration_action, :join_tables + private + # Sets the default migration template that is being used for the generation of the migration. # Depending on command line arguments, the migration template and the table name instance # variables are set up. - def set_local_assigns! + def set_local_assigns! # :doc: @migration_template = "migration.rb" case file_name when /^(add|remove)_.*_(?:to|from)_(.*)/ @@ -40,13 +42,13 @@ module ActiveRecord end end - def set_index_names + def set_index_names # :doc: attributes.each_with_index do |attr, i| attr.index_name = [attr, attributes[i - 1]].map { |a| index_name_for(a) } end end - def index_name_for(attribute) + def index_name_for(attribute) # :doc: if attribute.foreign_key? attribute.name else @@ -54,7 +56,6 @@ module ActiveRecord end.to_sym end - private def attributes_with_index attributes.select { |a| !a.reference? && a.has_index? } end diff --git a/activerecord/lib/rails/generators/active_record/model/model_generator.rb b/activerecord/lib/rails/generators/active_record/model/model_generator.rb index f1ddc61688..ff76881834 100644 --- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb +++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb @@ -33,31 +33,31 @@ module ActiveRecord hook_for :test_framework - protected + private - def attributes_with_index + def attributes_with_index # :doc: attributes.select { |a| !a.reference? && a.has_index? } end # FIXME: Change this file to a symlink once RubyGems 2.5.0 is required. - def generate_application_record + def generate_application_record # :doc: if self.behavior == :invoke && !application_record_exist? template "application_record.rb", application_record_file_name end end # Used by the migration template to determine the parent name of the model - def parent_class_name + def parent_class_name # :doc: options[:parent] || "ApplicationRecord" end - def application_record_exist? + def application_record_exist? # :doc: file_exist = nil in_root { file_exist = File.exist?(application_record_file_name) } file_exist end - def application_record_file_name + def application_record_file_name # :doc: @application_record_file_name ||= if mountable_engine? "app/models/#{namespaced_path}/application_record.rb" else |