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