Class: Gambiarra::History

Inherits:
Object
  • Object
show all
Defined in:
lib/gambiarra/history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHistory

Returns a new instance of History.



5
6
7
# File 'lib/gambiarra/history.rb', line 5

def initialize
  @routes = []
end

Instance Attribute Details

#routesObject (readonly)

Returns the value of attribute routes.



3
4
5
# File 'lib/gambiarra/history.rb', line 3

def routes
  @routes
end

Instance Method Details

#add(route) ⇒ Object



9
10
11
# File 'lib/gambiarra/history.rb', line 9

def add(route)
  @routes << route
end

#backObject



21
22
23
# File 'lib/gambiarra/history.rb', line 21

def back
  routes.pop.respond
end

#current_routeObject



17
18
19
# File 'lib/gambiarra/history.rb', line 17

def current_route
  routes[-1]
end

#previousObject



13
14
15
# File 'lib/gambiarra/history.rb', line 13

def previous
  routes[-2]&.path || ''
end

#refresh(**params) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/gambiarra/history.rb', line 25

def refresh(**params)
  return {
    content: 'Abnormal end',
    path: 'exit'
  } unless current_route

  current_route.respond(**params)
end