lib/codebreaker/user.rb in codebreaker_bo-0.1.3 vs lib/codebreaker/user.rb in codebreaker_bo-0.1.4

- old
+ new

@@ -1,23 +1,13 @@ # frozen_string_literal: true module Codebreaker class User < BaseClass - attr_accessor :errors attr_reader :name def initialize(player_name) - @errors = [] - validation_name(player_name) - @errors.empty? ? @name = player_name : show_errors super() - end - - def validation_name(player_name) - if player_name.is_a?(String) - @errors << 'error min length or max length' unless Constants::LENGTH_RANGE.include?(player_name.length) - else - @errors << 'name is not string' - end + validation_name(player_name) + @name = player_name if valid? end end end