stair_master 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -10,10 +10,11 @@ module StairMaster
|
|
10
10
|
include ::StairMaster::Concerns::Getters
|
11
11
|
include ::StairMaster::Concerns::Ordering
|
12
12
|
include ::StairMaster::Concerns::Tests
|
13
|
+
include ::StairMaster::Concerns::Routing
|
13
14
|
|
14
15
|
included do
|
15
|
-
helper_method :workflow_map
|
16
|
-
before_filter :check_step_availability
|
16
|
+
helper_method :workflow_map, :params_for_redirect
|
17
|
+
before_filter :check_step_availability, only: [:show, :update]
|
17
18
|
end
|
18
19
|
|
19
20
|
def workflow_map
|
@@ -22,11 +23,22 @@ module StairMaster
|
|
22
23
|
|
23
24
|
private # ---------------------------------------------
|
24
25
|
|
26
|
+
## Override this method in your controller to set the params
|
27
|
+
def params_for_redirect(*bad_keys)
|
28
|
+
mod_params = params
|
29
|
+
default_keys = [:action, :controller, :authenticity_token, :utf8]
|
30
|
+
(bad_keys + default_keys).each do |k|
|
31
|
+
mod_params.delete k
|
32
|
+
end
|
33
|
+
|
34
|
+
mod_params.empty? ? nil : mod_params
|
35
|
+
end
|
36
|
+
|
25
37
|
def check_step_availability
|
26
38
|
if is_available_step?
|
27
|
-
redirect_to
|
39
|
+
redirect_to next_step_path(params_for_redirect) if step_should_be_skipped?
|
28
40
|
else
|
29
|
-
redirect_to
|
41
|
+
redirect_to first_step_path(params_for_redirect)
|
30
42
|
end
|
31
43
|
end
|
32
44
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# lib/stair_master/concerns/routing.rb
|
2
|
+
##
|
3
|
+
##
|
4
|
+
module StairMaster
|
5
|
+
module Concerns
|
6
|
+
module Routing
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
helper_method :current_step_path,
|
11
|
+
:next_step_path,
|
12
|
+
:previous_step_path,
|
13
|
+
:first_step_path
|
14
|
+
end
|
15
|
+
|
16
|
+
def current_step_path(resources=[],options={})
|
17
|
+
current_step.url_for resources, options
|
18
|
+
end
|
19
|
+
|
20
|
+
def next_step_path(resources=[],options={})
|
21
|
+
next_step.url_for resources, options
|
22
|
+
end
|
23
|
+
|
24
|
+
def previous_step_path(resources=[],options={})
|
25
|
+
previous_step.url_for resources, options
|
26
|
+
end
|
27
|
+
|
28
|
+
def first_step_path(resources=[],options={})
|
29
|
+
first_step.url_for resources, options
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/stair_master/step.rb
CHANGED
@@ -31,9 +31,11 @@ module StairMaster
|
|
31
31
|
|
32
32
|
def url_for(resources=[], options={})
|
33
33
|
begin
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
## TODO: There is probably a better way to handle this.
|
35
|
+
resources = resources.nil? ? [] : resources
|
36
|
+
Rails.application.routes.url_helpers.send @path.to_sym, (resources.empty? ? nil : resources), options
|
37
|
+
rescue Exception => e
|
38
|
+
raise RuntimeError, "Could not find the route '#{ @path }' in your application. #{ e.message }"
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
data/lib/stair_master/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stair_master
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-01-
|
13
|
+
date: 2014-01-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- lib/stair_master/concerns.rb
|
195
195
|
- lib/stair_master/concerns/getters.rb
|
196
196
|
- lib/stair_master/concerns/ordering.rb
|
197
|
+
- lib/stair_master/concerns/routing.rb
|
197
198
|
- lib/stair_master/concerns/tests.rb
|
198
199
|
- lib/stair_master/concerns/traversal.rb
|
199
200
|
- lib/stair_master/conditions.rb
|
@@ -273,7 +274,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
273
274
|
version: '0'
|
274
275
|
segments:
|
275
276
|
- 0
|
276
|
-
hash:
|
277
|
+
hash: 689621588319283352
|
277
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
278
279
|
none: false
|
279
280
|
requirements:
|
@@ -282,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
283
|
version: '0'
|
283
284
|
segments:
|
284
285
|
- 0
|
285
|
-
hash:
|
286
|
+
hash: 689621588319283352
|
286
287
|
requirements: []
|
287
288
|
rubyforge_project:
|
288
289
|
rubygems_version: 1.8.24
|