aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-30 11:52:59 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-30 11:52:59 -0300
commit8c77b0a086bb47ef7cd4b827460a51613f94094e (patch)
tree01b0853bc38a5d1504196b7e2ebeb3f0e0e225a0 /activesupport/lib
parentc36c7fc747dfc723bcee647103dcff0be885234f (diff)
parent3a0888203031b91a583f8ce35763f8d231467827 (diff)
downloadrails-8c77b0a086bb47ef7cd4b827460a51613f94094e.tar.gz
rails-8c77b0a086bb47ef7cd4b827460a51613f94094e.tar.bz2
rails-8c77b0a086bb47ef7cd4b827460a51613f94094e.zip
Merge pull request #15313 from andreychernih/time-with-zone-string-conversion-speed-up
Speed-up TimeWithZone to String conversion
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index f2a2f3c3db..3155c0ab0f 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -353,6 +353,14 @@ module ActiveSupport
initialize(variables[0].utc, ::Time.find_zone(variables[1]), variables[2].utc)
end
+ # respond_to_missing? is not called in some cases, such as when type conversion is
+ # performed with Kernel#String
+ def respond_to?(sym, include_priv = false)
+ # ensure that we're not going to throw and rescue from NoMethodError in method_missing which is slow
+ return false if sym.to_sym == :to_str
+ super
+ end
+
# Ensure proxy class responds to all methods that underlying time instance
# responds to.
def respond_to_missing?(sym, include_priv)