aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2018-03-01 21:09:24 -0800
committerJeremy Daer <jeremydaer@gmail.com>2018-03-01 22:42:51 -0800
commit4b42c7e52aa23081ce02ffad53c76ab786214e87 (patch)
tree3ce3c19d1b336c490cdbf2d8a5f93716480f1939 /activemodel
parent6a029624009eee9fab04c186ccbe06862f5a231f (diff)
downloadrails-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 'activemodel')
-rw-r--r--activemodel/lib/active_model/attributes.rb2
-rw-r--r--activemodel/lib/active_model/type/binary.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/attributes.rb b/activemodel/lib/active_model/attributes.rb
index 4083bf827b..7d44f7f2a3 100644
--- a/activemodel/lib/active_model/attributes.rb
+++ b/activemodel/lib/active_model/attributes.rb
@@ -29,7 +29,7 @@ module ActiveModel
private
def define_method_attribute=(name)
- safe_name = name.unpack("h*".freeze).first
+ safe_name = name.unpack1("h*".freeze)
ActiveModel::AttributeMethods::AttrNames.set_name_cache safe_name, name
generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
diff --git a/activemodel/lib/active_model/type/binary.rb b/activemodel/lib/active_model/type/binary.rb
index dc2eca18be..76203c5a88 100644
--- a/activemodel/lib/active_model/type/binary.rb
+++ b/activemodel/lib/active_model/type/binary.rb
@@ -40,7 +40,7 @@ module ActiveModel
alias_method :to_str, :to_s
def hex
- @value.unpack("H*")[0]
+ @value.unpack1("H*")
end
def ==(other)