respond_for_helper 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/lib/respond_for_helper/formats/base.rb +2 -2
- data/lib/respond_for_helper/respond.rb +13 -6
- data/lib/respond_for_helper/version.rb +1 -1
- 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: 8662ea79ffb98d16f4a82182e8837f1153a6b6dceeee39781b7750df0bb7209c
|
4
|
+
data.tar.gz: 209badd08e4669c9717406c8f92e1ecc9d65ac3de4fa507749b59c0a9c990e25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e797d9bb30f9399629de7c7cccbb4f1af93f6647521cd4c9617e38e6ac9ec2eb3aa42121890484d2df6a40d2b4d17f0a99df56853f9da343aea177ef0aa76a61
|
7
|
+
data.tar.gz: 16416c8c03b0332d0863368da138fdc377c551d92fc71be8ae8cdfc566b50c98221ff0a3665be42ce8eb838e1f4fb37418abd66b0e18d4af873834fd2c631c18
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -8,13 +8,13 @@ module RespondForHelper
|
|
8
8
|
attr_reader :controller, :item, :format, :result, :behaviour
|
9
9
|
delegate :request, :render, :head, :redirect_to, :flash, :url_for, :action_name, to: :controller
|
10
10
|
|
11
|
-
def initialize(controller, item, options)
|
11
|
+
def initialize(controller, item, success, options)
|
12
12
|
@controller = controller
|
13
13
|
@item = item
|
14
|
+
@result = success ? :success : :failure
|
14
15
|
@options = options
|
15
16
|
|
16
17
|
@format = self.class.format.to_sym
|
17
|
-
@result = @options[:success] ? :success : :failure
|
18
18
|
@behaviour = Behaviours.new(@controller, @format, @result, @options).call
|
19
19
|
end
|
20
20
|
|
@@ -7,15 +7,22 @@ module RespondForHelper
|
|
7
7
|
@item = item
|
8
8
|
@options = options
|
9
9
|
|
10
|
-
|
11
|
-
@options[:success] = Array(item).all? { |item| item.errors.blank? }
|
12
|
-
end
|
13
|
-
|
10
|
+
@success = check_success
|
14
11
|
@callbacks = {}
|
15
12
|
end
|
16
13
|
|
14
|
+
def check_success
|
15
|
+
if @options.key?(:success)
|
16
|
+
@options[:success]
|
17
|
+
elsif @controller.request.get?
|
18
|
+
true
|
19
|
+
else
|
20
|
+
Array(@item).all? { |item| item.errors.blank? }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
17
24
|
def success?
|
18
|
-
@
|
25
|
+
@success
|
19
26
|
end
|
20
27
|
|
21
28
|
def before_success(&block)
|
@@ -64,7 +71,7 @@ module RespondForHelper
|
|
64
71
|
|
65
72
|
def formatters
|
66
73
|
Lookups::Format.new(@controller, @options).call.map do |_, klass|
|
67
|
-
klass.new(@controller, @item, @options)
|
74
|
+
klass.new(@controller, @item, @success, @options)
|
68
75
|
end
|
69
76
|
end
|
70
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: respond_for_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshikazu Kaneta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|