From 7ebef567ce30d848dd8f9374fd70699fd91acb29 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 25 Jul 2016 00:31:35 +0200 Subject: systematic revision of =~ usage in AV Where appropriate, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with? --- actionview/lib/action_view/layouts.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'actionview/lib/action_view/layouts.rb') diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb index 8db1674187..8e956c47c6 100644 --- a/actionview/lib/action_view/layouts.rb +++ b/actionview/lib/action_view/layouts.rb @@ -1,5 +1,6 @@ -require "action_view/rendering" -require "active_support/core_ext/module/remove_method" +require 'action_view/rendering' +require 'active_support/core_ext/module/remove_method' +require 'active_support/core_ext/regexp' module ActionView # Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in @@ -279,7 +280,7 @@ module ActionView def _write_layout_method # :nodoc: remove_possible_method(:_layout) - prefixes = _implied_layout_name =~ /\blayouts/ ? [] : ["layouts"] + prefixes = /\blayouts/.match?(_implied_layout_name) ? [] : ["layouts"] default_behavior = "lookup_context.find_all('#{_implied_layout_name}', #{prefixes.inspect}, false, [], { formats: formats }).first || super" name_clause = if name default_behavior -- cgit v1.2.3