govuk-wizardry 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/wizardry_helper.rb +1 -1
- data/lib/wizardry/instance.rb +1 -1
- data/lib/wizardry/version.rb +1 -1
- data/lib/wizardry.rb +30 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63518ea4a2c566ad33949be35f38ae906c74a76ccfe1b476733d4b44ef832472
|
4
|
+
data.tar.gz: f1841013e966dce14787c53a1968abe29c113da01eab96985cc2a0e1e8bd49c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 524640ac8f8c936aaca7be0a3587eb170d451949e394e685e743518b74e040a0954d5ae9b10108f17134c216523675f2c2580a9a246c59fb3cb8065806edf47b
|
7
|
+
data.tar.gz: 6ca5e77eb8918d55fbaf68fd017395866f0d7876ed201ecb4d44a2c02091a25e14a18bca3d6bbb8c95d81da36ad74a749d6f2cd87ba4639d0457728ea92f1af7
|
data/lib/wizardry/instance.rb
CHANGED
data/lib/wizardry/version.rb
CHANGED
data/lib/wizardry.rb
CHANGED
@@ -58,7 +58,7 @@ module Wizardry
|
|
58
58
|
@wizard.current_page.after_update!(@wizard.object)
|
59
59
|
Rails.logger.debug("🧙 Object saved and callbacks run, moving on")
|
60
60
|
|
61
|
-
|
61
|
+
finish if @wizard.complete?
|
62
62
|
end
|
63
63
|
|
64
64
|
redirect_to send(@wizard.framework.edit_path_helper, @wizard.next_page.name.to_s.dasherize)
|
@@ -71,14 +71,22 @@ module Wizardry
|
|
71
71
|
|
72
72
|
private
|
73
73
|
|
74
|
-
def
|
75
|
-
Rails.logger.debug("🧙 Wizard complete,
|
74
|
+
def finish
|
75
|
+
Rails.logger.debug("🧙 Wizard complete, finishing off")
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
finalize_object!
|
78
|
+
clear_identifier!
|
79
|
+
end
|
80
|
+
|
81
|
+
def finalize_object!(finalize_method: :finalize!)
|
82
|
+
Rails.logger.debug("🧙 Trying to finalize object")
|
83
|
+
|
84
|
+
if @wizard.object.respond_to?(finalize_method)
|
85
|
+
Rails.logger.debug("🧙 Object has #{finalize_method} method - calling it")
|
86
|
+
|
87
|
+
@wizard.object.send(finalize_method)
|
80
88
|
else
|
81
|
-
Rails.logger.warn("🧙 Wizard object has no #{
|
89
|
+
Rails.logger.warn("🧙 Wizard object has no #{finalize_method} method")
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
@@ -109,7 +117,21 @@ module Wizardry
|
|
109
117
|
end
|
110
118
|
|
111
119
|
def identifier
|
112
|
-
cookies.fetch(wizard.cookie_name) {
|
120
|
+
cookies.fetch(wizard.cookie_name) { set_identifier! }
|
121
|
+
end
|
122
|
+
|
123
|
+
def set_identifier!
|
124
|
+
identifier = SecureRandom.uuid
|
125
|
+
|
126
|
+
Rails.logger.debug("🧙 Setting cookie #{identifier}")
|
127
|
+
|
128
|
+
cookies[wizard.cookie_name] = identifier
|
129
|
+
end
|
130
|
+
|
131
|
+
def clear_identifier!
|
132
|
+
Rails.logger.debug("🧙 Clearing cookie")
|
133
|
+
|
134
|
+
cookies.delete(wizard.cookie_name)
|
113
135
|
end
|
114
136
|
end
|
115
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-wizardry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Yates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk-components
|