responders 2.2.0 → 2.3.0
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +4 -4
- data/lib/action_controller/respond_with.rb +4 -2
- data/lib/responders/flash_responder.rb +22 -10
- data/lib/responders/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: a0c692c9db8d41efad52bc5dcbe523d7ffae971a
|
4
|
+
data.tar.gz: ec9fab6aee728b24ac40a984c3d186a023a3d488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7359a3b96df95cd3faba4c416f9fdb183fb75f6a7ec429e8377a13efd542e1f434c585d93e5cfe7f1ba4d16e1cdc3b617a6cd2ec7b5f99fd5f41cc6f8cd38229
|
7
|
+
data.tar.gz: cdbd028d24c15b5225b06174dd8776b3200dc0d3c6ffada06b49c5a3341c9bc26d0bff1df27509187d94f763fd57a83b9dd4619bf46f69d65959d4937f022123
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
## 2.3.0
|
4
|
+
|
5
|
+
* `verify_request_format!` is aliased to `verify_requested_format!` now.
|
6
|
+
* Implementing the `interpolation_options` method on your controller is deprecated
|
7
|
+
in favor of naming it `flash_interpolation_options` instead.
|
8
|
+
|
1
9
|
## 2.2.0
|
2
10
|
|
3
11
|
* Added the `verify_request_format!` method, that can be used as a `before_action`
|
data/README.md
CHANGED
@@ -160,7 +160,7 @@ end
|
|
160
160
|
|
161
161
|
## Interpolation Options
|
162
162
|
|
163
|
-
You can pass in extra interpolation options for the translation by adding an `
|
163
|
+
You can pass in extra interpolation options for the translation by adding an `flash_interpolation_options` method to your controller:
|
164
164
|
|
165
165
|
```ruby
|
166
166
|
class InvitationsController < ApplicationController
|
@@ -173,7 +173,7 @@ class InvitationsController < ApplicationController
|
|
173
173
|
|
174
174
|
private
|
175
175
|
|
176
|
-
def
|
176
|
+
def flash_interpolation_options
|
177
177
|
{ resource_name: @invitation.email }
|
178
178
|
end
|
179
179
|
end
|
@@ -222,13 +222,13 @@ end
|
|
222
222
|
mime type was not configured through the class level `respond_to`, but the
|
223
223
|
action will still be executed and any side effects (like creating a new record)
|
224
224
|
will still occur. To raise the `UnknownFormat` exception before your action
|
225
|
-
is invoked you can set the `
|
225
|
+
is invoked you can set the `verify_requested_format!` method as a `before_action`
|
226
226
|
on your controller.
|
227
227
|
|
228
228
|
```ruby
|
229
229
|
class WidgetsController < ApplicationController
|
230
230
|
respond_to :json
|
231
|
-
before_action :
|
231
|
+
before_action :verify_requested_format!
|
232
232
|
|
233
233
|
# POST /widgets.html won't reach the `create` action.
|
234
234
|
def create
|
@@ -216,9 +216,9 @@ module ActionController #:nodoc:
|
|
216
216
|
# class PeopleController < ApplicationController
|
217
217
|
# respond_to :html, :xml, :json
|
218
218
|
#
|
219
|
-
# before_action :
|
219
|
+
# before_action :verify_requested_format!
|
220
220
|
# end
|
221
|
-
def
|
221
|
+
def verify_requested_format!
|
222
222
|
mimes = collect_mimes_from_class_level
|
223
223
|
collector = ActionController::MimeResponds::Collector.new(mimes, request.variant)
|
224
224
|
|
@@ -227,6 +227,8 @@ module ActionController #:nodoc:
|
|
227
227
|
end
|
228
228
|
end
|
229
229
|
|
230
|
+
alias :verify_request_format! :verify_requested_format!
|
231
|
+
|
230
232
|
# Collect mimes declared in the class method respond_to valid for the
|
231
233
|
# current action.
|
232
234
|
def collect_mimes_from_class_level #:nodoc:
|
@@ -33,9 +33,9 @@ module Responders
|
|
33
33
|
# notice: "Hooray! You just tuned your %{car_brand}!"
|
34
34
|
#
|
35
35
|
# Since :car_name is not available for interpolation by default, you have
|
36
|
-
# to overwrite
|
36
|
+
# to overwrite `flash_interpolation_options` in your controller.
|
37
37
|
#
|
38
|
-
# def
|
38
|
+
# def flash_interpolation_options
|
39
39
|
# { :car_brand => @car.brand }
|
40
40
|
# end
|
41
41
|
#
|
@@ -147,25 +147,37 @@ module Responders
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def mount_i18n_options(status) #:nodoc:
|
150
|
-
resource_name = if resource.class.respond_to?(:model_name)
|
151
|
-
resource.class.model_name.human
|
152
|
-
else
|
153
|
-
resource.class.name.underscore.humanize
|
154
|
-
end
|
155
|
-
|
156
150
|
options = {
|
157
151
|
:default => flash_defaults_by_namespace(status),
|
158
152
|
:resource_name => resource_name,
|
159
153
|
:downcase_resource_name => resource_name.downcase
|
160
154
|
}
|
161
155
|
|
162
|
-
|
163
|
-
|
156
|
+
controller_options = controller_interpolation_options
|
157
|
+
if controller_options
|
158
|
+
options.merge!(controller_options)
|
164
159
|
end
|
165
160
|
|
166
161
|
options
|
167
162
|
end
|
168
163
|
|
164
|
+
def controller_interpolation_options
|
165
|
+
if controller.respond_to?(:flash_interpolation_options, true)
|
166
|
+
controller.send(:flash_interpolation_options)
|
167
|
+
elsif controller.respond_to?(:interpolation_options, true)
|
168
|
+
ActiveSupport::Deprecation.warn("[responders] `#{controller.class}#interpolation_options` is deprecated, please rename it to `flash_interpolation_options`.")
|
169
|
+
controller.send(:interpolation_options)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def resource_name
|
174
|
+
if resource.class.respond_to?(:model_name)
|
175
|
+
resource.class.model_name.human
|
176
|
+
else
|
177
|
+
resource.class.name.underscore.humanize
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
169
181
|
def flash_defaults_by_namespace(status) #:nodoc:
|
170
182
|
defaults = []
|
171
183
|
slices = controller.controller_path.split('/')
|
data/lib/responders/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|