なるようになるブログ

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

rails commit log流し読み(2014/08/26)

2014/08/26分のコミットです。

CHANGELOGへの追加はありませんでした。


[ci skip] use proper apostrophe

activesupport/test/transliterate_test.rbのコメントの修正です。

ダブルアポストロフィをシングルアポストロフィに修正。


[ci skip] make assert messages consistent

activemodel/test/cases/validations_test.rbの修正です。

assertメソッドに指定したメッセージが実際の結果と異なっていたのを修正しています。


Use ActiveSupport::Concern instead of the traditinal way

activemodel/lib/active_model/model.rbの修正です。

class_evalを使用してextend/includeを行っていたのを、ActiveSupport::Concernを使用してロードするよう修正しています。

-    def self.included(base) #:nodoc:
-      base.class_eval do
-        extend  ActiveModel::Naming
-        extend  ActiveModel::Translation
-        include ActiveModel::Validations
-        include ActiveModel::Conversion
-      end
+    extend ActiveSupport::Concern
+    include ActiveModel::Validations
+    include ActiveModel::Conversion
+
+    included do
+      extend ActiveModel::Naming
+      extend ActiveModel::Translation
     end

ちょっと好みがわかれそうな気もしますが…。


Quick pass through the 4.2 release notes [ci skip]

rails guideのRuby on Rails 4.2 Release Notesの修正です。

typoの修正、改行の追加、クォーテーションの追加等を対応しています。


Added web links

rails guideのRuby on Rails 4.2 Release Notesの修正です。

Resque、Delayed Job、Sidekiqについて、githubのリンクを追加しています。


Fixed find_by("sql fragment without bindings") on master

activerecord/lib/active_record/core.rbの修正です。

find_byメソッドの引数チェック処理を修正しています。

-        return super if current_scope || args.length > 1 || reflect_on_all_aggregations.any?
+        return super if current_scope || !(Hash === args.first) || reflect_on_all_aggregations.any?

元々は、argsの長さをチェックしていたのを、型チェックを行うように変更しています。

Todo.all.find_by("id = ?", 1)

こんな使い方をした場合に、find_byメソッド内で処理を行えるようにする為、だとは思うのですが、何故この対応が必要かはよく解らず…。


Override #find_by! in core to enable AST caching

activerecord/lib/active_record/core.rbの修正です。

Coreモジュールにfind_by!メソッドを定義しています。ASTキャッシングの為との事です。


Merge pull request #16646 from sgrif/sg-perf-regression

activerecord/lib/active_record/attribute_methods/dirty.rbの修正です。

changed_attributesの値をcacheするよう修正しています。


[ci skip] Added documentation for has_and_belongs_to_many extension parameter

activerecord/lib/active_record/associations.rbのdocの修正です。

has_and_belongs_to_manyのエクステンションにパラメータを渡す場合のサンプルを追加しています。

has_and_belongs_to_many :contractors do
  def find_or_create_by_name(name)
    first_name, last_name = name.split(" ", 2)
    find_or_create_by(first_name: first_name, last_name: last_name)
  end
end

[ActiveJob] Autoload adapters

ActiveJobの修正です。

requireしていた各adapterのロード処理を、autoloadで自動的に読み込むよう修正しています。