Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/timecop/time_extensions.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.mock_timeObject



6
7
8
9
# File 'lib/timecop/time_extensions.rb', line 6

def mock_time
  mocked_time_stack_item = Timecop.top_stack_item
  mocked_time_stack_item.nil? ? nil : mocked_time_stack_item.time(self)
end

.new_with_mock_time(*args, **kwargs) ⇒ Object Also known as: new



21
22
23
24
25
26
27
28
29
# File 'lib/timecop/time_extensions.rb', line 21

def new_with_mock_time(*args, **kwargs)
  if args.empty? && kwargs.empty?
    now
  elsif kwargs.any?
    new_without_mock_time(*args, **kwargs)
  else
    new_without_mock_time(*args)
  end
end

.now_with_mock_timeObject Also known as: now



13
14
15
# File 'lib/timecop/time_extensions.rb', line 13

def now_with_mock_time
  mock_time || now_without_mock_time
end