なるようになるブログ

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

rails commit log流し読み(2016/07/23)

2016/07/23分のコミットです。

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

activesupport/CHANGELOG.md


systematic revision of =~ usage in AS

Active Supportの修正です。

Regexp#=~を使用している箇所を、Regexp#match?を使用するよう修正しています。Ruby 2.4だとRegexp#match?の方が高速だからですね。

また、そもそも正規表現を使う必要の無い箇所を、String#include?String#start_with?等を使用して修正しています。


revises a regexp

activesupport/lib/active_support/inflector/methods.rbの修正です。

ActiveSupport::Inflector#safe_constantizeメソッドで行っているエラーがnot missing constantによるものかどうかのチェック処理何で、不要なエスケープ処理があったのを削除しています。


Merge pull request #25914 from jmccartie/jm/not_in

Active Supportの修正です。

Objectnot_in?メソッドを追加しています。

def not_in?(another_object)
  !another_object.include?(self)
rescue NoMethodError
  raise ArgumentError.new("The parameter passed to #not_in? must respond to #include?")
end

中身はこれだけ。[1,2].exclude?(user_id)と書いてたのが、user_id.not_in?([1,2])と書けるようになります。便利っちゃ便利か。


Explain meaning of the code very well and Remove confusion. [ci skip]

actionview/lib/action_view/helpers/cache_helper.rbのdoc及びrails guideのCaching with Rails: An Overviewの修正です。

renderメソッドのexampleを修正しています。

-      #   render "header" => render("comments/header")
+      #   render "header" translates to render("comments/header")

=>だとHashと勘違いしてしまい紛らわしい為、との事です。