2015/08/08分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
activemodel/CHANGELOG.md
Remove XML Serialization from core.
ActiveModel、ActiveRecordの修正です。
rails本体からActiveModel::Serializers::Xml
、 ActiveRecord::Serialization::XmlSerializer
、ActiveRecord::Serialization#to_xml
を削除し、外部gem(activemodel-serializers-xml
)に切り出しています。
Regexp#=== is faster than String#=~
activesupport/lib/active_support/inflector/inflections.rb
の修正です。
Inflections#uncountable?
メソッドでマッチ処理をするのに、String#=~
ではなく、Regexp#===
を使用するよう修正しています。Regexp#===
の方が高速な為との事。参考ベンチ。
require 'benchmark/ips' def fast "foo".freeze =~ /boo/ end def slow "foo".freeze.match(/boo/) end Benchmark.ips do |x| x.report("String#=~") { fast } x.report("String#match") { slow } x.compare! end
Calculating ------------------------------------- String#=~ 69.889k i/100ms String#match 66.715k i/100ms ------------------------------------------------- String#=~ 1.854M (±12.2%) i/s - 9.155M String#match 1.594M (±11.0%) i/s - 7.939M Comparison: String#=~: 1853861.7 i/s String#match: 1593971.6 i/s - 1.16x slower
the request class is never changed, so just use it directly in the method body
actionpack/lib/action_controller/metal.rb
、
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
Metal.action
の引数からclassを指定する為の引数を削除しています。
ActionDispatch::Request
以外のclassを使用する事が無い為、引数から削除し、固定でRequest
クラスを使用するようにしています。
use Proc.new to reduce some conditionals
actionpack/lib/action_dispatch/middleware/stack.rb
の修正です。
MiddlewareStack::Middleware#stack
メソッドの引数の指定に&block
ではなくProc.new
を使用するよう修正しています。
- def build(app = nil, &block) - app ||= block - raise "MiddlewareStack#build requires an app" unless app + def build(app = Proc.new) middlewares.freeze.reverse.inject(app) { |a, e| e.build(a) }
Proc.new
だとメソッドの呼び出し時に指定されたblockを自動でピックアップしてくれて、渡されなかった場合自動でArgumentErrorになり、
コンディションチェックが減らせる為Proc.new
を使用するよ修正したとの事です。
simplify the Middleware constructor
actionpack/lib/action_controller/metal.rb
、
actionpack/lib/action_dispatch/middleware/stack.rb
の修正です。
MiddlewareStack::Middleware
のコンストラクタで行っていたパラメータのパース処理をbuild_middleware
メソッドに切り出して、
コンストラクタはシンプルにリファクタリングしています。
move valid?
conditional to the constructor
actionpack/lib/action_controller/metal.rb
の修正です。
MiddlewareStack::Middleware
クラスのコンストラクタの引数にStrategyを指定出来るようにして、valid?
メソッドの処理を指定されたStrategyに移譲するよう修正しています。
Using strings or symbols for middleware class names is deprecated.
ActionPackの修正です。
middleware classの指定にString or Symbolを使用するのがdeprecateになりました。今後はClassのみ指定可能です。
# NG middleware.use "Foo::Bar" # OK middleware.use Foo::Bar
finish deprecating handling strings and symbols
ActionPackの修正です。
Middleware
の指定がClassのみになった為、string / symbolが指定された場合の一部処理、不要になったテスト等を削除しています。
stop using @_env in the controller instance
ActionPackの修正です。
controllerのインスタンスから_env
変数を削除し、env hashへのアクセスが必要な場合、かならずrequest object経由で値の取得を行うよう修正しています。
actionpack/lib/action_controller/middleware.rb
の修正です。
もう使用していないと思われるActionMiddleware
クラスを削除しています。
the request object manages env
actionpack/lib/action_controller/metal.rb
の修正です。
Metal#env
へのセッターメソッドを削除しています。 env hashはrequest objectで管理しており、controllerから設定する事は無い為。
deprecate the env method on controller instances
actionpack/lib/action_controller/metal.rb
、
actionpack/lib/action_controller/metal/streaming.rb
の修正です。
controller instanceのenv methodをdeprecateにしています。env hashへのアクセスが必要な場合、request objectを経由してアクセスするように、との事です。
[ci skip] Add an explanation for status
option
rails guideのRails Routing from the Outside In
の修正です。
Redirection
の項に、redirect
メソッドのstatusオプションについての説明を追記しています。
use uuid method to define the UUID type [ci skip]
rails guideのActive Record and PostgreSQL
の修正です。
UUID型を使用するeampleで、カラムを定義するのにcolumn
メソッドを使用していたのを、uuid
メソッドを使用するよう修正しています。
Refactor to remove DrawOnce module
actionpack/test/abstract_unit.rb
の修正です。
テストに使う為のrouteの定義を別moduleにおこない、それをincludeしてテストしていたのですが、別moduleに切り出す必要は無いだろう、 という事でテストクラス無いに直接routesを定義するよう修正しています。
Rename extra_keys
variables to query_string_keys
actionpack/lib/action_controller/test_case.rb
、
actionpack/lib/action_dispatch/testing/assertions/routing.rb
の修正です。
generate_extras
メソッドの戻り値を格納する変数名をextra_keys
から query_string_keys
に変更しています。
extra
だと意味がわからないので、より格納している値の意味がわかりやすい名前に変更しています。
Fix deprecation warning in tests
middleware の指定に文字列を使用していた箇所をクラス名を指定するよう修正しています。
先の、Using strings or symbols for middleware class names is deprecated. によりdeprecationメッセージが出るようになってしまった為、対応しています。