From 5e06f8b956acab52f5360a75ed3589b84b32eff3 Mon Sep 17 00:00:00 2001 From: Richard Towers Date: Wed, 15 Jan 2025 09:56:25 +0000 Subject: [PATCH] Move early returns out of begin blocks returning early from a begin block won't assign the variable, but it sort of looks like it will. Clearer / more explicit to have the early returns outside the block. --- app/presenters/manual_section_presenter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/presenters/manual_section_presenter.rb b/app/presenters/manual_section_presenter.rb index 559b7ac08..27324a54d 100644 --- a/app/presenters/manual_section_presenter.rb +++ b/app/presenters/manual_section_presenter.rb @@ -11,9 +11,9 @@ def base_path end def intro - @intro ||= begin - return nil unless details["body"] + return nil unless details["body"] + @intro ||= begin intro = Nokogiri::HTML::DocumentFragment.parse(details["body"]) # Strip all content following and including h2 @@ -29,9 +29,9 @@ def visually_expanded? end def main - @main ||= begin - return nil unless details["body"] + return nil unless details["body"] + @main ||= begin document = Nokogiri::HTML::DocumentFragment.parse(details["body"]) # Identifies all h2's and creates an array of objects from the heading and