なるようになるブログ

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

rails commit log流し読み(2014/05/14)

2014/05/14分のコミットです。

親子両方のクラスでActiveRecord::Storeを使用している場合に、正しくマージされないバグの修正が行われています。


Fix assertion order and :scissors: extra spaces

actionview/test/template/translation_helper_test.rbの修正です。

テストメソッド名の修正及び、assert_equalの引数の順番を修正しています。


[postgres] include PgArrayParser directly and only load/include ArrayParser if not found

PostgresqlのConnectionAdapterに関する修正です。

必ずinclude ConnectionAdapters::PostgreSQLColumn::ArrayParserしていたのを、pg_array_parseがロード出来なかった時だけincludeするよう修正しています。

include処理が減るので、少し性能改善になるのでは、という事です。


Use i18n master to run tests

Gemfileの修正です。i18nをmasterを参照するようにしています。


options already have symbolized keys, so we can avoid this call

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

options.symbolize_keysしていたのを、既にsymbolized済み、との事でsymbolize_keysを削除しています。


the :only_path option is applied by the time the helper is called

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

options[:host]の値に応じて:only_pathオプションの設定を行っていたのですが、:only_pathオプションはヘルパーが呼ばれた時のも適応する、との事なので、ここではオプションの設定処理を行わないように修正しています。


just merge instead of dup and merge

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

dup..merge!していたのを、mergeだけするように修正しています。


use fewer method calls to determine the url_for options

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

メソッド呼び出し減らすようリファクタリングしています。


Remove falsy deprecation note in AS guides [ci skip]

rails guideの"Active Support Core Extensions"のページの修正です。

deprecation対象からdeprecation対象では無くなったファイルがあり、その記述を削除しています。


calls with :host should still use the optimized path

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

OptimizedUrlHelper:hostの値が必要なので、チェック処理を追加した、かなあ…。


[ci skip] Fix a factual error and highlight code in generators guide.

rails guideの"Creating and Customizing Rails Generators & Templates"のページの修正です。

シングルコーテーションを追加しています。


options should always be passed to url_for

ActionDispatch::Routing::RouteSet#url_forメソッドの修正です。

元々引数のoptionsにnilを許容していたのを、nilは受け付けない想定に修正しています。

とはいえ、元々nilがきてもエラーになるだけだったような気も。


this method should always have a parameter passed to it, so remove the default

ActionDispatch::Routing::RouteSet#_generate_prefixメソッドの修正です。

引数のデフォルト値を設定したのを、引数は必ず渡されるので、デフォルト値を削除しています。


extend with a module then use define_method

ActionDispatch::Routing::RouteSet#define_generate_prefixメソッドの修正です。

redefine_methodでメソッドの拡張をしていたのをdefine_methodを使うよう修正しています。定義されている事は無いから、でしょうか。


no need to check for presence, script names can be blank

ActionDispatch::Routing::RouteSet#url_forメソッドの修正です。

:script_name及び:original_script_namepresenceチェックを行っていたのを、削除しています。

nilでなくて、空文字列で問題無いからですかね。


drop || test for cases that do not need it

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

||で存在チェックしていた処理をメソッドに切り出して||を削除しています。


remove deprecation warning

ActiveSupport::Callbacks#define_callbacksの修正です。

deprecateになっていたoptionにterminatorが指定された時の処理が削除されています。


we never call url_for with a block, so rm

ActionDispatch::Routing::RouteSet#url_forメソッドの修正です。

yieldメソッド呼び出し処理を削除しています。

url_forblock付きで呼ばれる事が無いから、との事。


_recall should be set to a hash or not set

ActionDispatch::Routing::RouteSet#url_forメソッドの修正です。

_recallオプションがnilの時に、空のハッシュを設定してます。以降nilチェック処理を避ける為、との事。


begin refactoring delete_records method

ActiveRecord::Associations::CollectionAssociation::HasManyAssociation#delete_recordsメソッドのリファクタリングです。

delete_all_recordsdelete_countメソッドを新規に作成して、delete_recordsの一部処理を切り出していいます。


remove need for :all symbol

上の続き。こちらはActiveRecord::Associations::CollectionAssociation::HasManyAssociation#delete_countメソッドのリファクタリングです。

引数の修正をしています。


rename delete_all_records to delete_or_nullify_all_records

上の続き。delete_all_recordsメソッドをdelete_or_nullify_all_recordsに修正しています。

HasManyAssociationHasManyThroughAssociation両方です。


remove count var

上の続き。こちらはActiveRecord::Associations::CollectionAssociation::HasManyAssociation#delete_or_nullify_all_recordsメソッドの修正です。

不要な修正処理を行ってしまったらしく、処理を戻しています。


minor: point to the right test suite location

actionview/test/template/sanitize_helper_test.rbのdocの修正です。

ポインティングしているファイル名が誤っていたのを修正しています。


Fix inheritance of stored_attributes (fixes #14672)

ActiveRecord::Storeの修正です。

親子両方のクラスでstored_attributesを使用している際に、正しく値のマージが出来ていなかったバグの修正が行われています。

テストケースから抜粋。

  first_model = Class.new(ActiveRecord::Base) do
    store_accessor :data, :color
  end
  second_model = Class.new(first_model) do
    store_accessor :data, :width, :height
  end
  third_model = Class.new(first_model) do
    store_accessor :data, :area, :volume
  end

  assert_equal [:color], first_model.stored_attributes[:data]
  assert_equal [:color, :width, :height], second_model.stored_attributes[:data]
  assert_equal [:color, :area, :volume], third_model.stored_attributes[:data]

親クラスのActiveRecord::Baseで指定したstoreの値が、子供のsecond_modelthird_modelでも参照出来るんですねえ。

因みに、ActiveRecord::Store知りませんでした。 JSONがそのまま入れれるのは便利ですね。PostgresqlだとJSON / HStore使えば済むのですが、MySQLの時は重宝しそう。