respond_for_helper 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c9d236367624f955240459dad1d1757ed3757e9fe59823ec0ba6a829cf41d8c
4
- data.tar.gz: 3c06d61ccd843cc4e41f82decbc4088b51c5e96bf0801fe0409b08b9d16fe0b0
3
+ metadata.gz: 8662ea79ffb98d16f4a82182e8837f1153a6b6dceeee39781b7750df0bb7209c
4
+ data.tar.gz: 209badd08e4669c9717406c8f92e1ecc9d65ac3de4fa507749b59c0a9c990e25
5
5
  SHA512:
6
- metadata.gz: 5c0c9fcd0b643e30b9ea9ae801a8f3d11cee1b36b7df7fd737d3d148ab57dc41e11b6b9de8d0e1887e32c2698b96ded6ed01e7456752748c9950ed61c92818b7
7
- data.tar.gz: 2fec9caf0d96d44190d720493bc8c27141fe1a247cbca1a8fe2185a9d98c751f37a1aaa2e748a3a6b3b3687f75027e0ffb5b043be7e3d4f75bb758c89a3e7c4e
6
+ metadata.gz: e797d9bb30f9399629de7c7cccbb4f1af93f6647521cd4c9617e38e6ac9ec2eb3aa42121890484d2df6a40d2b4d17f0a99df56853f9da343aea177ef0aa76a61
7
+ data.tar.gz: 16416c8c03b0332d0863368da138fdc377c551d92fc71be8ae8cdfc566b50c98221ff0a3665be42ce8eb838e1f4fb37418abd66b0e18d4af873834fd2c631c18
@@ -46,7 +46,7 @@ jobs:
46
46
  BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
47
47
 
48
48
  steps:
49
- - uses: actions/checkout@v2
49
+ - uses: actions/checkout@v3
50
50
  - uses: ruby/setup-ruby@v1
51
51
  with:
52
52
  ruby-version: ${{ matrix.ruby }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.2
4
+
5
+ * Skip checking errors when request method is get.
6
+
3
7
  ## 1.1.1
4
8
 
5
9
  * Use `Time.zone.now` if possible.
@@ -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
- unless @options.key?(:success)
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
- @options[:success]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RespondForHelper
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
5
5
  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.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-10-13 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails