diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2018-03-01 21:09:24 -0800 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2018-03-01 22:42:51 -0800 |
commit | 4b42c7e52aa23081ce02ffad53c76ab786214e87 (patch) | |
tree | 3ce3c19d1b336c490cdbf2d8a5f93716480f1939 /activerecord/lib | |
parent | 6a029624009eee9fab04c186ccbe06862f5a231f (diff) | |
download | rails-4b42c7e52aa23081ce02ffad53c76ab786214e87.tar.gz rails-4b42c7e52aa23081ce02ffad53c76ab786214e87.tar.bz2 rails-4b42c7e52aa23081ce02ffad53c76ab786214e87.zip |
Ruby 2.4: take advantage of String#unpack1
https://bugs.ruby-lang.org/issues/12752
https://ruby-doc.org/core-2.4.0/String.html#method-i-unpack1
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/write.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index 4077250583..14f700b6a9 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -27,7 +27,7 @@ module ActiveRecord # Making it frozen means that it doesn't get duped when used to # key the @attributes in read_attribute. def define_method_attribute(name) - safe_name = name.unpack("h*".freeze).first + safe_name = name.unpack1("h*".freeze) temp_method = "__temp__#{safe_name}" ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name diff --git a/activerecord/lib/active_record/attribute_methods/write.rb b/activerecord/lib/active_record/attribute_methods/write.rb index bb0ec6a8c3..c7521422bb 100644 --- a/activerecord/lib/active_record/attribute_methods/write.rb +++ b/activerecord/lib/active_record/attribute_methods/write.rb @@ -13,7 +13,7 @@ module ActiveRecord private def define_method_attribute=(name) - safe_name = name.unpack("h*".freeze).first + safe_name = name.unpack1("h*".freeze) ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name sync_with_transaction_state = "sync_with_transaction_state" if name == primary_key |