なるようになるブログ

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

rails commit log流し読み(2014/06/30)

2014/06/30分のコミットです。

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

activesupport/CHANGELOG.md

Add Hash#map_values to ActiveSupport


Merge pull request #15961 from mckramer/patch-1

actionview/lib/action_view/helpers/date_helper.rbの修正です。

time_ago_in_wordsメソッドの引数名を、適切な名前にリネームしています。


Quick pass through Active Support and guides CHANGELOG

activesupportとguideのCHANGELOGの修正です。

不要なスペース・改行を削除しています。


Tiny documentation fixes [ci skip]

actionviewactivesupport、guideの各docの修正です。

exampleの変数名の修正、+の追加等々。


Don't encourage usage of columns_hash

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

column_for_attributeメソッドで指定されたカラム名が存在しなかった場合に、代わりにmodel.class.columns_hash[name]を使うようwarningを出力していたのですが、直接hash参照するのはよくない、という事で代わりにattribute_exists?を新規に作成して、こちらのメソッドを使うようwarningを修正しています。


Use the type object for sending JSON to the database

PostgreSQLのConnectionAdapterの修正です。

Castmoduleで行っていたJSONの変換処理をtype配下のJsonクラスで処理を行うよう修正しています。


Add Hash#map_values to ActiveSupport

Hash#transform_valuesHash#transform_values!メソッドを新規に作成しています。

{ a: 1, b: 2, c: 3 }.transform_values { |x| x * 2 }  # => { a: 2, b: 4, c: 6 } 

valueに対して、引数のブロックを実行した結果を設定するメソッドのようですね。keyは変わりません。!破壊メソッド版。


Simplify creation of default attributes on AR instance

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

initializeメソッドでの@attributesの生成処理をself.class.default_attributes.dupに修正しています。


Use Hash#transform_values to clean up AttributeSet

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

早速先ほど追加されたHash#transform_valuesメソッドを使用するよう修正しています。


Use the type object when sending point columns to the DB

PostgreSQLのConnectionAdapterの修正です。

Castmoduleで行っていたPointの変換処理をtype配下のPointクラスで処理を行うよう修正しています。


Remove array workaround in PG quoting

activerecord/lib/active_record/connection_adapters/postgresql/quoting.rbの修正です。

arrayに関するquote処理を削除しています。

もう不要なワークアラウンド処理でとの事。


Remove unused array_member from PG quoting for HStore columns

activerecord/lib/active_record/connection_adapters/postgresql/cast.rbactiverecord/lib/active_record/connection_adapters/postgresql/quoting.rbの修正です。

使用していないarray_member変数を削除しています。


Update documentation on STI change handling

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

サブクラスはインスタンス生成時にdirtyマークがついている旨説明追加しています。

class Company < ActiveRecord::Base; end
class Firm < Company; end 

Company.new.changed? # => false
Firm.new.changed? # => true
Firm.new.changes # => {"type"=>["","Firm"]}

これ知らなかったです。changesメソッド、こんな動きするんですねえ。