From 805b603cac5c5d273dae90009157a2b0fc7fc5b8 Mon Sep 17 00:00:00 2001 From: Shu Fujita Date: Fri, 17 Jan 2020 22:35:31 +0900 Subject: [PATCH 1/2] Refactor Annotate::Helpers.true? --- lib/annotate/helpers.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/annotate/helpers.rb b/lib/annotate/helpers.rb index fb44924e3..1dbb53ccc 100644 --- a/lib/annotate/helpers.rb +++ b/lib/annotate/helpers.rb @@ -15,10 +15,7 @@ def include_models? end def true?(val) - return false if val.blank? - return false unless val =~ Constants::TRUE_RE - - true + val.present? && Constants::TRUE_RE.match?(val) end def fallback(*args) From 4dcd9e009aa72f0ab476e547a8e32e715302d6cb Mon Sep 17 00:00:00 2001 From: Shu Fujita Date: Fri, 17 Jan 2020 22:43:32 +0900 Subject: [PATCH 2/2] Refactor Annotate::Helpers.fallback --- lib/annotate/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/annotate/helpers.rb b/lib/annotate/helpers.rb index 1dbb53ccc..705685790 100644 --- a/lib/annotate/helpers.rb +++ b/lib/annotate/helpers.rb @@ -19,7 +19,7 @@ def true?(val) end def fallback(*args) - args.detect { |arg| !arg.blank? } + args.detect(&:present?) end def reset_options(options)