class Gambiarra::History

Attributes

routes[R]

Public Class Methods

new() click to toggle source
# File lib/gambiarra/history.rb, line 5
def initialize
  @routes = []
end

Public Instance Methods

add(route) click to toggle source
# File lib/gambiarra/history.rb, line 9
def add(route)
  @routes << route
end
back() click to toggle source
# File lib/gambiarra/history.rb, line 21
def back
  routes.pop.respond
end
current_route() click to toggle source
# File lib/gambiarra/history.rb, line 17
def current_route
  routes[-1]
end
previous() click to toggle source
# File lib/gambiarra/history.rb, line 13
def previous
  routes[-2]&.path || ''
end
refresh(**params) click to toggle source
# File lib/gambiarra/history.rb, line 25
def refresh(**params)
  return {
    content: 'Abnormal end',
    path: 'exit'
  } unless current_route

  current_route.respond(**params)
end