File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ def extract_expiry_time(time_or_duration)
5555 # then use it and convert result to Integer
5656 # 3. Otherwise invoke #to_i on the argument and interpret it as a number of milliseconds
5757 def extract_duration ( number_or_duration )
58- return number_or_duration if number_or_duration . is_a? Integer
58+ return unless number_or_duration
59+ return number_or_duration if number_or_duration . class == Integer # rubocop:disable Style/ClassEqualityComparison avoid overrides of #is_a?, #kind_of?
5960
6061 if number_or_duration . respond_to? ( :in_milliseconds )
6162 number_or_duration . public_send ( :in_milliseconds )
Original file line number Diff line number Diff line change @@ -51,4 +51,8 @@ def test_accepts_floats
5151 def test_interpret_integer_as_a_milliseconds_literal
5252 assert_equal 42 , Couchbase ::Utils ::Time . extract_duration ( 42 )
5353 end
54+
55+ def test_ignores_nil_argument
56+ assert_nil Couchbase ::Utils ::Time . extract_duration ( nil )
57+ end
5458end
You can’t perform that action at this time.
0 commit comments