Module: SimpleWorkflow::Detour
- Included in:
- Controller, Helper, Middleware
- Defined in:
- lib/simple_workflow/detour.rb
Overview
Utility methods to manage the breadcrumb history
Instance Method Summary collapse
- #pop_detour(session, origin_options = nil) ⇒ Object
- #reset_workflow(session) ⇒ Object
- #store_detour_in_session(session, options) ⇒ Object
Instance Method Details
#pop_detour(session, origin_options = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_workflow/detour.rb', line 21 def pop_detour(session, = nil) detours = session[:detours] return nil unless detours detour = detours.delete() || detours.pop Rails.logger.debug { "popped detour: #{detour.inspect} #{session[:detours].size} more" } reset_workflow(session) if detours.empty? detour end |
#reset_workflow(session) ⇒ Object
31 32 33 |
# File 'lib/simple_workflow/detour.rb', line 31 def reset_workflow(session) session.delete(:detours) end |
#store_detour_in_session(session, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/simple_workflow/detour.rb', line 5 def store_detour_in_session(session, ) if session[:detours] if session[:detours].last == Rails.logger.try(:debug, "Ignored duplicate detour: #{.inspect}") return end if session[:detours].delete() Rails.logger.try(:debug, "Deleted duplicate detour: #{.inspect}") end else session[:detours] = [] end session[:detours] << Rails.logger.try(:debug, "Added detour (#{session[:detours].try(:size) || 0}): #{.inspect}") end |