aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2009-04-05 10:08:54 -0500
committerGeoff Buesing <gbuesing@gmail.com>2009-04-05 10:08:54 -0500
commitc00f2d25de640b8de1c8583474085f3836ee1768 (patch)
tree22f03541c018920e31a4865d827ea40f9763b200 /activesupport
parent70de8e64e30092b2b1b77869e459b4868f5b9577 (diff)
downloadrails-c00f2d25de640b8de1c8583474085f3836ee1768.tar.gz
rails-c00f2d25de640b8de1c8583474085f3836ee1768.tar.bz2
rails-c00f2d25de640b8de1c8583474085f3836ee1768.zip
TimeWithZone.name returns 'Time', to further thwart type checking
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb5
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb4
3 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 2acce97646..2ba96c390b 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*Edge
+* TimeWithZone.name returns 'Time', to further thwart type checking [Geoff Buesing]
+
* Time.local instances: Adding 24.hours across the DST boundary adds 24 hours instead of one day #2066 [Michael Curtis]
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 518ca7742f..2574f4e88e 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -31,6 +31,11 @@ module ActiveSupport
# t.is_a?(Time) # => true
# t.is_a?(ActiveSupport::TimeWithZone) # => true
class TimeWithZone
+
+ def self.name
+ 'Time' # Report class name as 'Time' to thwart type checking
+ end
+
include Comparable
attr_reader :time_zone
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index accfe51ed6..7be19e7900 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -317,6 +317,10 @@ class TimeWithZoneTest < Test::Unit::TestCase
assert @twz.kind_of?(Time)
assert @twz.is_a?(ActiveSupport::TimeWithZone)
end
+
+ def test_class_name
+ assert_equal 'Time', ActiveSupport::TimeWithZone.name
+ end
def test_method_missing_with_time_return_value
assert_instance_of ActiveSupport::TimeWithZone, @twz.months_since(1)