Class: Gambiarra::History
- Inherits:
-
Object
- Object
- Gambiarra::History
- Defined in:
- lib/gambiarra/history.rb
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
- #add(route) ⇒ Object
- #back ⇒ Object
- #current_route ⇒ Object
-
#initialize ⇒ History
constructor
A new instance of History.
- #previous ⇒ Object
- #refresh(**params) ⇒ Object
Constructor Details
#initialize ⇒ History
Returns a new instance of History.
5 6 7 |
# File 'lib/gambiarra/history.rb', line 5 def initialize @routes = [] end |
Instance Attribute Details
#routes ⇒ Object (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 |
#back ⇒ Object
21 22 23 |
# File 'lib/gambiarra/history.rb', line 21 def back routes.pop.respond end |
#current_route ⇒ Object
17 18 19 |
# File 'lib/gambiarra/history.rb', line 17 def current_route routes[-1] end |
#previous ⇒ Object
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 |