aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-04-15 21:41:19 -0400
committerJon Moss <me@jonathanmoss.me>2017-01-02 19:05:09 -0500
commitfeacb99003813d10425bd861d4dae3a14e4a33fb (patch)
treea9ef80e431938fa930863eef75b2468f5f2db141 /actionpack/lib/action_controller
parent33e60514aed85b3076f2636d5f1ccfb513aace1c (diff)
downloadrails-feacb99003813d10425bd861d4dae3a14e4a33fb.tar.gz
rails-feacb99003813d10425bd861d4dae3a14e4a33fb.tar.bz2
rails-feacb99003813d10425bd861d4dae3a14e4a33fb.zip
Extract variant setter to process method
Provide an API interface similar to how format is handled in Controllers. In situations where variants are not needed (ex: in Action Mailer) the method will simply trigger a no-op, and will not affect end users.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index cdd09e832b..4c01891d4c 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -54,6 +54,12 @@ module ActionController
private
+ def _process_variant(options)
+ if defined?(request) && !request.nil? && request.variant.present?
+ options[:variant] = request.variant
+ end
+ end
+
def _render_in_priorities(options)
RENDER_FORMATS_IN_PRIORITY.each do |format|
return options[format] if options.key?(format)