From 675a39bb021ba2105d8100f82bbfcfb5c2fb6e70 Mon Sep 17 00:00:00 2001 From: Kevin De Pelseneer Date: Tue, 22 Oct 2024 12:04:13 +0200 Subject: [PATCH] Restructure constraints More readable --- .../sample_type_editing_constraints.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/seek/samples/sample_type_editing_constraints.rb b/lib/seek/samples/sample_type_editing_constraints.rb index 9f599e503e..bf298d2bd8 100644 --- a/lib/seek/samples/sample_type_editing_constraints.rb +++ b/lib/seek/samples/sample_type_editing_constraints.rb @@ -26,11 +26,11 @@ def allow_required?(attr) attr = attr.accessor_name end - if attr - !blanks?(attr) - else - !samples? - end + + return false unless attr + return !blanks?(attr) if samples? + + true end # an attribute could be removed if all are currently blank @@ -56,11 +56,10 @@ def allow_name_change?(attr) attr = attr.accessor_name end - if attr - samples.all?(&:can_edit?) - else - true - end + return false unless attr + return samples.all?(&:can_edit?) if samples? + + true end # whether the type for the attribute can be changed