提交 810dff7c 编写于 作者: X Xavier Noria

RuboCop is 100% green 🎉

上级 11eaf1c1
......@@ -34,11 +34,12 @@ def register_preview_interceptors(*interceptors)
# Either a class or a string can be passed in as the Interceptor. If a
# string is passed in it will be <tt>constantize</tt>d.
def register_preview_interceptor(interceptor)
preview_interceptor = case interceptor
when String, Symbol
interceptor.to_s.camelize.constantize
preview_interceptor = \
case interceptor
when String, Symbol
interceptor.to_s.camelize.constantize
else
interceptor
interceptor
end
unless preview_interceptors.include?(preview_interceptor)
......
......@@ -62,7 +62,7 @@ def default_render(*args)
def method_for_action(action_name)
super || if template_exists?(action_name.to_s, _prefixes)
"default_render"
end
end
end
private
......
......@@ -282,16 +282,17 @@ def define_url_helper(mod, route, name, opts, route_key, url_strategy)
mod.module_eval do
define_method(name) do |*args|
last = args.last
options = case last
when Hash
args.pop
when ActionController::Parameters
if last.permitted?
args.pop.to_h
else
raise ArgumentError, ActionDispatch::Routing::INSECURE_URL_PARAMETERS_MESSAGE
end
end
options = \
case last
when Hash
args.pop
when ActionController::Parameters
if last.permitted?
args.pop.to_h
else
raise ArgumentError, ActionDispatch::Routing::INSECURE_URL_PARAMETERS_MESSAGE
end
end
helper.call self, args, options
end
end
......
......@@ -1011,12 +1011,13 @@ def build_select(type, select_options_as_html)
# css_class_attribute(:year, 'date optional', { year: 'my-year' })
# => "date optional my-year"
def css_class_attribute(type, html_options_class, options) # :nodoc:
css_class = case options
when Hash
options[type.to_sym]
else
type
end
css_class = \
case options
when Hash
options[type.to_sym]
else
type
end
[html_options_class, css_class].compact.join(" ")
end
......
......@@ -8,7 +8,7 @@ def cast(value)
when false then 0
when ::String then value.presence
else value
end
end
super(value)
end
......
......@@ -21,7 +21,7 @@ def cast_value(value)
when true then "t"
when false then "f"
else value.to_s
end
end
result.freeze
end
end
......
......@@ -14,18 +14,19 @@ module Reflection # :nodoc:
end
def self.create(macro, name, scope, options, ar)
klass = case macro
when :composed_of
AggregateReflection
when :has_many
HasManyReflection
when :has_one
HasOneReflection
when :belongs_to
BelongsToReflection
else
raise "Unsupported Macro: #{macro}"
end
klass = \
case macro
when :composed_of
AggregateReflection
when :has_many
HasManyReflection
when :has_one
HasOneReflection
when :belongs_to
BelongsToReflection
else
raise "Unsupported Macro: #{macro}"
end
reflection = klass.new(name, scope, options, ar)
options[:through] ? ThroughReflection.new(reflection) : reflection
......
......@@ -208,7 +208,11 @@ def test_to_json
end
def test_case_when
cased = case 1.day when 1.day then "ok" end
cased = \
case 1.day
when 1.day
"ok"
end
assert_equal cased, "ok"
end
......
......@@ -67,14 +67,15 @@ def convert_notes(body)
# as a list item, but as a paragraph starting with a plain
# asterisk.
body.gsub(/^(TIP|IMPORTANT|CAUTION|WARNING|NOTE|INFO|TODO)[.:](.*?)(\n(?=\n)|\Z)/m) do
css_class = case $1
when "CAUTION", "IMPORTANT"
"warning"
when "TIP"
"info"
else
$1.downcase
end
css_class = \
case $1
when "CAUTION", "IMPORTANT"
"warning"
when "TIP"
"info"
else
$1.downcase
end
%(<div class="#{css_class}"><p>#{$2.strip}</p></div>)
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册