state_machine_buttons 0.1.0 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/state_machine_buttons/renderer.rb +7 -6
- data/lib/state_machine_buttons/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2281ef49c3ce8b2c1716385e0d87972aa5ba44e8
|
4
|
+
data.tar.gz: 9a317f931fbd0885a74731f9f36ebebbc0c1fb44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c7d5cec1df817b6ac7b00fd01ecf16e8e79e0b0331b6d61406c3bd51cf7cd44911df25879dbcd8d328f13ece75400cd8cc372ac6c898745e9065c683a9ae0e8
|
7
|
+
data.tar.gz: a2df6c70d123ae8d302b2600face18bb963f26f0240ea2005c62c8009294e47710545f27d06ccc73b5535a8567a2a20928fc0c3c091382f0ec0cc58b81c05c7f
|
@@ -2,23 +2,24 @@
|
|
2
2
|
|
3
3
|
module StateMachineButtons
|
4
4
|
module Renderer
|
5
|
-
def state_events_buttons(object, state_method: :state, url: nil, without: nil)
|
5
|
+
def state_events_buttons(object, state_method: :state, url: nil, without: nil, namespace: nil)
|
6
6
|
model_name = object.model.model_name.name.underscore
|
7
|
-
excepted_actions = without.is_a?(Array) ? without.map(&:to_sym) : [without.to_sym]
|
7
|
+
excepted_actions = without.is_a?(Array) ? without.map(&:to_sym) : [without.to_sym] if without
|
8
8
|
transitions = object.model.send("#{state_method}_transitions").reject do |t|
|
9
|
-
excepted_actions.include?
|
9
|
+
excepted_actions.present? && excepted_actions.include?(t.event)
|
10
10
|
end
|
11
11
|
content_tag(:div, class: 'btn-group-vertical') do
|
12
12
|
transitions.each do |event|
|
13
|
-
button event: event, model_name: model_name, object: object, state_method: state_method, url: url
|
13
|
+
button event: event, model_name: model_name, object: object, state_method: state_method, url: url, namespace: namespace
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def button(event:, model_name:, object:, state_method:, url:)
|
21
|
-
|
20
|
+
def button(event:, model_name:, object:, state_method:, url:, namespace:)
|
21
|
+
route_method_name = "#{namespace.present? ? "#{namespace}_": ""}#{model_name.gsub('/', '_')}_path"
|
22
|
+
href = url || send(route_method_name, object.model, model_name => { state_method => event.to })
|
22
23
|
concat(
|
23
24
|
link_to(
|
24
25
|
href,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_machine_buttons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|