action-segue 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/action-segue.gemspec +1 -1
- data/lib/action_segue/segue_registration.rb +12 -13
- data/spec/fixtures/fake_application.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69ca200905097fba816b0117484140d14a6dbd16
|
4
|
+
data.tar.gz: 78024cea61aad887d0d6e2dc7f2158554f079d11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca68de33beeafee6644fc7404dfd86f745d69cbc4c2ed6fc767cc62084cd547e8dda3401177bda9ab36f561fdab70db15d432609500af4f09ef4eb3cb7beeb93
|
7
|
+
data.tar.gz: 84a622e9266e88721f248d74564b244e5801d22145856f5595d72689024ad2811246c4d9f8d29cd90a160a811805e7945a401e73cc384efcdd04efd117031dea
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
Then, at any point in the future, you can return to this segue start point. You must also pass in a fallback location which is used in the event no segue with the id is in progress.
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
|
20
|
+
redirect_to complete_segue_url(:looking_at_index, fallback: dashboard_path)
|
21
21
|
```
|
22
22
|
|
23
23
|
If you just want to clear a segue to remove it from the stack, you can use `clear_segue`:
|
@@ -29,7 +29,7 @@ clear_segue :looking_at_index
|
|
29
29
|
If you don't know (or care) what current segue is in progress (useful in situations where many actions could lead away from their flow, and you just want to return to the original flow), you can just complete the current segue. This also requires a fallback location in case there is no current segue in progress.
|
30
30
|
|
31
31
|
```ruby
|
32
|
-
|
32
|
+
redirect_to complete_current_segue_url(fallback: dashboard_path)
|
33
33
|
```
|
34
34
|
|
35
35
|
## TODO
|
data/action-segue.gemspec
CHANGED
@@ -12,29 +12,28 @@ module ActionSegue
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
# Completes the segue
|
16
|
-
# fallback
|
17
|
-
def
|
15
|
+
# Completes the segue and returns either the params to redirect to the segue start point,
|
16
|
+
# all the fallback if the segue is not in progress.
|
17
|
+
def complete_segue_url(id, fallback:)
|
18
18
|
if session[:action_segues].present? && session[:action_segues][id].present?
|
19
|
-
segue =
|
20
|
-
Rails.logger.debug "[ActionSegue] completed '#{id}'
|
21
|
-
|
19
|
+
segue = clear_segue id
|
20
|
+
Rails.logger.debug "[ActionSegue] completed '#{id}'"
|
21
|
+
url_for segue.params
|
22
22
|
else
|
23
|
-
Rails.logger.debug "[ActionSegue] no segue matched '#{id}'
|
24
|
-
|
23
|
+
Rails.logger.debug "[ActionSegue] no segue matched '#{id}'"
|
24
|
+
fallback
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
# Remove a segue from the stack
|
29
29
|
def clear_segue(id)
|
30
30
|
Rails.logger.debug "[ActionSegue] clearing segue '#{id}'"
|
31
|
-
session[:action_segues].delete
|
31
|
+
session[:action_segues].delete id
|
32
32
|
end
|
33
33
|
|
34
|
-
# Completes the last segue, regardless of what it was
|
35
|
-
|
36
|
-
|
37
|
-
complete_segue_with_redirect session[:action_segues].try(:keys).try(:last), or_redirect_to: or_redirect_to
|
34
|
+
# Completes the last segue, regardless of what it was
|
35
|
+
def complete_current_segue_url(fallback:)
|
36
|
+
complete_segue_url session[:action_segues].try(:keys).try(:last), fallback: fallback
|
38
37
|
end
|
39
38
|
|
40
39
|
end
|
@@ -35,7 +35,7 @@ class NamedSeguesController < ActionController::Base
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def segue_complete_page
|
38
|
-
|
38
|
+
redirect_to complete_segue_url(:named_segue, fallback: { action: :normal_page })
|
39
39
|
end
|
40
40
|
|
41
41
|
def segue_clear_page
|
@@ -48,7 +48,7 @@ class NamedSeguesController < ActionController::Base
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def segue_complete_last_page
|
51
|
-
|
51
|
+
redirect_to complete_current_segue_url(fallback: { action: :normal_page })
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|