Skip to content
This repository
Browse code

TimeWithZone.name returns 'Time', to further thwart type checking

  • Loading branch information...
commit c00f2d25de640b8de1c8583474085f3836ee1768 1 parent 70de8e6
Geoff Buesing gbuesing authored
2  activesupport/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *Edge
2 2
  3 +* TimeWithZone.name returns 'Time', to further thwart type checking [Geoff Buesing]
  4 +
3 5 * Time.local instances: Adding 24.hours across the DST boundary adds 24 hours instead of one day #2066 [Michael Curtis]
4 6
5 7
5 activesupport/lib/active_support/time_with_zone.rb
@@ -31,6 +31,11 @@ module ActiveSupport
31 31 # t.is_a?(Time) # => true
32 32 # t.is_a?(ActiveSupport::TimeWithZone) # => true
33 33 class TimeWithZone
  34 +
  35 + def self.name
  36 + 'Time' # Report class name as 'Time' to thwart type checking
  37 + end
  38 +
34 39 include Comparable
35 40 attr_reader :time_zone
36 41
4 activesupport/test/core_ext/time_with_zone_test.rb
@@ -317,6 +317,10 @@ def test_is_a
317 317 assert @twz.kind_of?(Time)
318 318 assert @twz.is_a?(ActiveSupport::TimeWithZone)
319 319 end
  320 +
  321 + def test_class_name
  322 + assert_equal 'Time', ActiveSupport::TimeWithZone.name
  323 + end
320 324
321 325 def test_method_missing_with_time_return_value
322 326 assert_instance_of ActiveSupport::TimeWithZone, @twz.months_since(1)

0 comments on commit c00f2d2

Please sign in to comment.
Something went wrong with that request. Please try again.