aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2017-10-24 23:49:21 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2018-12-20 10:37:15 +0900
commitf3c866a743bc6edc9b67b241e65e6acfccfd3992 (patch)
tree6e9d75583f7512a4622495b1f1c0d2f2f9b9b06e /activemodel/lib/active_model
parent097650c194a80004169423c696974c504228c460 (diff)
downloadrails-f3c866a743bc6edc9b67b241e65e6acfccfd3992.tar.gz
rails-f3c866a743bc6edc9b67b241e65e6acfccfd3992.tar.bz2
rails-f3c866a743bc6edc9b67b241e65e6acfccfd3992.zip
Unify _read_attribute definition to use &block
Thanks to ko1, passing block parameter to another method is significantly optimized in Ruby 2.5. https://bugs.ruby-lang.org/issues/14045 Thus we no longer need to keep this ugly hack.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/attribute_set.rb12
1 files changed, 2 insertions, 10 deletions
diff --git a/activemodel/lib/active_model/attribute_set.rb b/activemodel/lib/active_model/attribute_set.rb
index a890ee3932..4679b33852 100644
--- a/activemodel/lib/active_model/attribute_set.rb
+++ b/activemodel/lib/active_model/attribute_set.rb
@@ -37,16 +37,8 @@ module ActiveModel
attributes.each_key.select { |name| self[name].initialized? }
end
- if defined?(JRUBY_VERSION)
- # This form is significantly faster on JRuby, and this is one of our biggest hotspots.
- # https://github.com/jruby/jruby/pull/2562
- def fetch_value(name, &block)
- self[name].value(&block)
- end
- else
- def fetch_value(name)
- self[name].value { |n| yield n if block_given? }
- end
+ def fetch_value(name, &block)
+ self[name].value(&block)
end
def write_from_database(name, value)