Browse files

Use respond_to_missing for TimeWithZone

  • Loading branch information...
1 parent 9bda374 commit 14762dc5effbc7bb9ae94cb5af895a9a33512867 @marcandre marcandre committed May 5, 2012
@@ -311,10 +311,10 @@ def marshal_load(variables)
# 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)
# Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+.
@@ -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

0 comments on commit 14762dc

Please sign in to comment.