responders 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ba43cee72d6a197eff78818683a01dfe43814d3
4
- data.tar.gz: 37ceb10a23ee46f1ec142176eee690c33a98b73d
3
+ metadata.gz: a0c692c9db8d41efad52bc5dcbe523d7ffae971a
4
+ data.tar.gz: ec9fab6aee728b24ac40a984c3d186a023a3d488
5
5
  SHA512:
6
- metadata.gz: e198e8715fefd1e87c21d7a52ed255ad51445bdfe2eb83e0e8a5eb8845eae8d3b1e665217ce1ac6f836156abd1d56cff5a2082f48cfb6f44e3cabe875117125f
7
- data.tar.gz: c59cbdaf34207e264e7551bdd700f2d9afe200fa29c2a31672d79debce0979853c76ee8ce0500347f5ee8fb19ebf8b86fc270a45add262d06b4d9c43c7c7ae17
6
+ metadata.gz: 7359a3b96df95cd3faba4c416f9fdb183fb75f6a7ec429e8377a13efd542e1f434c585d93e5cfe7f1ba4d16e1cdc3b617a6cd2ec7b5f99fd5f41cc6f8cd38229
7
+ data.tar.gz: cdbd028d24c15b5225b06174dd8776b3200dc0d3c6ffada06b49c5a3341c9bc26d0bff1df27509187d94f763fd57a83b9dd4619bf46f69d65959d4937f022123
@@ -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 `interpolation_options` method to your controller:
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 interpolation_options
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 `verify_request_format!` method as a `before_action`
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 :verify_request_format!
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 :verify_request_format!
219
+ # before_action :verify_requested_format!
220
220
  # end
221
- def verify_request_format!
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 interpolation_options in your controller.
36
+ # to overwrite `flash_interpolation_options` in your controller.
37
37
  #
38
- # def interpolation_options
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
- if controller.respond_to?(:interpolation_options, true)
163
- options.merge!(controller.send(:interpolation_options))
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('/')
@@ -1,3 +1,3 @@
1
1
  module Responders
2
- VERSION = "2.2.0".freeze
2
+ VERSION = "2.3.0".freeze
3
3
  end
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.2.0
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-04-29 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties