Module: RailsTimeTravel::Controller

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
lib/rails_time_travel/controller.rb

Instance Method Summary collapse

Instance Method Details

#time_travelObject



15
16
17
18
19
20
21
22
# File 'lib/rails_time_travel/controller.rb', line 15

def time_travel
  if session[:timecop_date]
    logger.info "TIME TRAVEL START: #{session[:timecop_date]}"
    Timecop.travel(session[:timecop_date])
  else
    Timecop.return
  end
end

#time_travel_for_requestObject



9
10
11
12
13
# File 'lib/rails_time_travel/controller.rb', line 9

def time_travel_for_request
  time_travel
  yield
  time_travel_return
end

#time_travel_returnObject



24
25
26
27
# File 'lib/rails_time_travel/controller.rb', line 24

def time_travel_return
  logger.info 'TIME TRAVEL RETURN'
  Timecop.return
end