0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails6 のちょい足しな新機能を試す49(consumes? 編)

Posted at

はじめに

Rails 6 に追加されそうな新機能を試す第48段。 今回は、 consumes? 編です。
Rails 6 では、 ActiveSupport::Multibyte::Chars.consumes? を使うと DEPRECATION WARNING が表示されるようになります。(私は自分で使ったこともないし、使われているところを見たことも無いのですが...)

Ruby 2.6.3, Rails 6.0.0.rc1 で確認しました。Rails 6.0.0.rc1 は gem install rails --prerelease でインストールできます。

$ rails --version
Rails 6.0.0.rc1

簡単なスクリプトを作る

今回は、動作確認用の簡単なスクリプトを書いて確認します。

bin/consumes.rb
# !/usr/bin/env ruby
require 'active_support/core_ext'

puts '--- DEPRECATED WARNING ---'
p ActiveSupport::Multibyte::Chars.consumes?('あ')

puts '--- NO DEPRECATED WARNING ---'
p 'あ'.is_utf8?

Rails 6 では

実行すると DEPRECATION WARNING が表示されます。

$ bin/duration.rb
--- DEPRECATED WARNING ---
DEPRECATION WARNING: ActiveSupport::Multibyte::Chars.consumes? is deprecated and will be removed from Rails 6.1. Use string.is_utf8? instead. (called from <main> at bin/consumes:5)
true
--- NO DEPRECATED WARNING ---
true

試したソース

試したソースは以下にあります。
https://github.com/suketa/rails6_0_0rc1/tree/try049_deprecated_consumes

参考情報

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?