2017/10/21分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Add test cases for type
and foreign_type
in the reflections
activerecord/test/cases/reflection_test.rb
の修正です。
reflectionsのtype
とforeign_type
が正しく取得出来る事を確認するテストを追加しています。
activesupport/lib/active_support/core_ext/hash/slice.rb
の修正です。
Hash
にslice
メソッドが定義されていない場合のみメソッドを定義するように修正しています。Ruby 2.5ではRuby本体にHash#slice
メソッドが定義されている為。
Move HWIA specific logic for slice and slice! to HWIA class
activesupport/lib/active_support/core_ext/hash/slice.rb
、
activesupport/lib/active_support/hash_with_indifferent_access.rb
の修正です。
Hash#slice
、#slice!
メソッドにselfがHashWithIndifferentAccess
の場合の対応が含まれていたのを削除し、代わりにHashWithIndifferentAccess#slice
、HashWithIndifferentAccess#slice!
メソッドを追加し、そちらで対応するよう修正しています。
activesupport/lib/active_support/core_ext/hash/slice.rb
の修正です。
Hash#slice
メソッドが必ずHash
クラスのインスタンスを返すよう修正しています。
- keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if has_key?(k) } + keys.each_with_object(Hash.new) { |k, hash| hash[k] = self[k] if has_key?(k) }
元々はself.class
を返すようになっていたのですが、Rubyに組み込みのHash#slice
と挙動を合わせる為との事です。挙動が非互換なのですが、恐らく問題になるであるHashWithIndifferentAccess
については対応がされている(先のコミットでメソッドが追加されている)ので、大丈夫だろうという事で対応されています。
[Railties] require_relative => require
railtiesの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
require
よりrequire_relative
の方が高速な為、Using require_relative in the Rails codebaseで使える箇所は一通りrequire_relative
を使うよう対応がされました。ただ、2.4までのRubyだと、require_relative
はシンボリックリンク先のファイルをロード出来ない(Rubyのインストール先がシンボリックリンクを使用している場合ファイルをロード出来ずエラーになる)、という問題があった為、require_relative
を使用するのをやめるようにしています。
なお、上記ファイルロードの問題はRuby 2.5で対応済みです。
参考:
- https://github.com/rails/rails/pull/29638#issuecomment-331284273
- file.c: rb_check_realpath
- load.c: real path to load
以降各コンポーネントに対して同様の対応が行われています。
[Active Support] require_relative => require
Active Supportの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Active Model] require => require_relative
Active Modelの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Active Record] require => require_relative
Active Recordの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Action Pack] require => require_relative
Action Packの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Action View] require_relative => require
Action Viewの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Action Mailer] require_relative => require
Action Mailerの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Active Job] require_relative => require
Active Jobの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Action Cable] require_relative => require
Action Cableの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。
[Active Storage] require_relative => require
Active Storageの修正です。
コンポーネント内のファイルのロードにrequire_relative
を使用していたのを、require
を使用するよう修正しています。