なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2018/12/20)

2018/12/20分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

actioncable/CHANGELOG.md

actionmailer/CHANGELOG.md

actionpack/CHANGELOG.md

actionview/CHANGELOG.md

activejob/CHANGELOG.md

activemodel/CHANGELOG.md

activerecord/CHANGELOG.md

activestorage/CHANGELOG.md

activesupport/CHANGELOG.md

railties/CHANGELOG.md


Clarify implicit meaning of 'workers: 2' in parallelization tests.

railties/test/application/test_runner_test.rbの修正です。

parallel testの並列数を強制的に設定する為のヘルパーメソッドの名前を、わかりやすい名前(substitute_arguments_of_parallelize_method -> exercise_parallelization_regardless_of_machine_core_count)に変更しています。


Require Ruby 2.5 for Rails 6.

色々と相談があった結果、Rails 6がサポートするバージョンはRuby 2.5以上となり、required_ruby_version>= 2.5.0に修正、不要なメソッドの削除等を行っています。


fix tests for mail 2.8

actionmailer/test/base_test.rbの修正です。

mail gem 2.8でmessage id戻り値が変更される事によりエラーになってしまうテストがあったのを修正しています。

2.8はまだリリースされてはいないのですが、先行して対応しています。

関連:Handle a wide variety of non-rfc Message-Id formats


Merge pull request #30973 from k0kubun/prefer-block-parameter

activemodel/lib/active_model/attribute_set.rbactiverecord/lib/active_record/attribute_methods/read.rbの修正です。

JRuby とそれ以外の処理系とでブロックに関する処理を分けている箇所があったのを、どの処理系でも同じ処理(ブロックパラメータを使用する方法)を行うよう修正しています。

-      if defined?(JRUBY_VERSION)
-        # This form is significantly faster on JRuby, and this is one of our biggest hotspots.
-        # https://github.com/jruby/jruby/pull/2562
-        def _read_attribute(attr_name, &block) # :nodoc:
-          @attributes.fetch_value(attr_name.to_s, &block)
-        end
-      else
-        def _read_attribute(attr_name) # :nodoc:
-          @attributes.fetch_value(attr_name.to_s) { |n| yield n if block_given? }
-        end
+      def _read_attribute(attr_name, &block) # :nodoc
+        @attributes.fetch_value(attr_name.to_s, &block)
      end

元々CRubyではブロックパラメータを使うと遅くなるという問題があった為上記のような処理になっていたのですが、Ruby 2.5でブロックパラメータを用いたブロック渡しが高速化されている、かつ、今のmasterではRuby 2.5以上のみをサポートするようなった為、上記修正を行っています。


Use native Array#append, Array#prepend, Hash#transform_keys, and Hash#transform_keys!

Active Supportの修正です。

Array#append, Array#prepend, Hash#transform_keys, Hash#transform_keys!メソッドを削除しています。Ruby 2.5以上をサポートしたことにより、これらのメソッドは必ずRubyに定義されている為。