Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use respond_to_missing for TimeWithZone

  • Loading branch information...
commit 14762dc5effbc7bb9ae94cb5af895a9a33512867 1 parent 9bda374
@marcandre marcandre authored
View
6 activesupport/lib/active_support/time_with_zone.rb
@@ -311,10 +311,10 @@ def marshal_load(variables)
end
# Ensure proxy class responds to all methods that underlying time instance responds to.
- def respond_to?(sym, include_priv = false)
+ def respond_to_missing?(sym, include_priv)
# consistently respond false to acts_like?(:date), regardless of whether #time is a Time or DateTime
- return false if sym.to_s == 'acts_like_date?'
- super || time.respond_to?(sym, include_priv)
+ return false if sym.to_sym == :acts_like_date?
+ time.respond_to?(sym, include_priv)
end
# Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+.
View
1  activesupport/test/core_ext/time_with_zone_test.rb
@@ -450,6 +450,7 @@ def test_instance_created_with_local_time_enforces_fall_dst_rules
def test_ruby_19_weekday_name_query_methods
%w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name|
assert_respond_to @twz, name
+ assert_equal @twz.send(name), @twz.method(name).call
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.