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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d69556f8e5237a6c112f20962f608f174f37cbc7
4
- data.tar.gz: 999a724ac87d3ccbcd19606066e522cf12209c79
3
+ metadata.gz: 69ca200905097fba816b0117484140d14a6dbd16
4
+ data.tar.gz: 78024cea61aad887d0d6e2dc7f2158554f079d11
5
5
  SHA512:
6
- metadata.gz: fabc1c0a66b0002846f37e7bd8a4f13dfa9d29d323a6d714b930e3d23366cd8125bdbeed92467156c4c06831d4dbd92b1600cf2131c0b0c0a1ee706db2f6750c
7
- data.tar.gz: 4fe3ed51cb51b1a32a1203172f212aaa56f07a945178d2a20cbb8f32630474d9420977ae540cae0b20a84dfedf52f9a06eda239ede7ba69290c2e00ba8872dd5
6
+ metadata.gz: ca68de33beeafee6644fc7404dfd86f745d69cbc4c2ed6fc767cc62084cd547e8dda3401177bda9ab36f561fdab70db15d432609500af4f09ef4eb3cb7beeb93
7
+ data.tar.gz: 84a622e9266e88721f248d74564b244e5801d22145856f5595d72689024ad2811246c4d9f8d29cd90a160a811805e7945a401e73cc384efcdd04efd117031dea
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- action-segue (1.0.1)
4
+ action-segue (1.1.0)
5
5
  railties (>= 4.2.0, < 5)
6
6
 
7
7
  GEM
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
- complete_segue_with_redirect :looking_at_index, or_redirect_to: dashboard_path
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
- complete_current_segue_with_redirect or_redirect_to: dashboard_path
32
+ redirect_to complete_current_segue_url(fallback: dashboard_path)
33
33
  ```
34
34
 
35
35
  ## TODO
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "action-segue"
5
- s.version = "1.0.1"
5
+ s.version = "1.1.0"
6
6
  s.authors = ["Damien Timewell"]
7
7
  s.email = ["mail@damientimewell.com"]
8
8
  s.licenses = ['MIT']
@@ -12,29 +12,28 @@ module ActionSegue
12
12
  end
13
13
  end
14
14
 
15
- # Completes the segue named ++id++ and redirects back to the start point, or
16
- # fallback url.
17
- def complete_segue_with_redirect(id, or_redirect_to:)
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 = session[:action_segues].delete(id)
20
- Rails.logger.debug "[ActionSegue] completed '#{id}'. Redirecting to #{or_redirect_to}"
21
- redirect_to url_for(segue.params)
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}'. Redirecting to #{or_redirect_to}"
24
- redirect_to or_redirect_to
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(id)
31
+ session[:action_segues].delete id
32
32
  end
33
33
 
34
- # Completes the last segue, regardless of what it was, or redirects to the fallback
35
- # if no segues are in progress.
36
- def complete_current_segue_with_redirect(or_redirect_to:)
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
- complete_segue_with_redirect :named_segue, or_redirect_to: { action: :normal_page }
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
- complete_current_segue_with_redirect or_redirect_to: { action: :normal_page }
51
+ redirect_to complete_current_segue_url(fallback: { action: :normal_page })
52
52
  end
53
53
 
54
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action-segue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Timewell