Module: WithAccounts::ErrorsHelpers
- Included in:
- ApplicationController, Jwts::AccessTokensCreating::CheckRefreshToken, Jwts::AccessTokensCreating::FindAndCheckAccount, Jwts::RefreshTokensCreating::CheckLoginInvitation, LoginInvitationsCreating::CheckParams, LoginInvitationsCreating::FindAndCheckAccount, LoginInvitationsCreating::SendEmailToUser, LoginInvitationsCreating::UpdateAccountLoginInvitation, PasswordsCreating::CheckParams, PasswordsCreating::CheckPasswordSetInvitation, PasswordsCreating::UpdateAccount
- Defined in:
- lib/with_accounts/errors_helpers.rb
Instance Method Summary collapse
Instance Method Details
#error_key ⇒ Object
3 4 5 |
# File 'lib/with_accounts/errors_helpers.rb', line 3 def error_key self.class.name.demodulize.to_sym end |
#format_errors(errors_hash) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/with_accounts/errors_helpers.rb', line 7 def format_errors(errors_hash) raise StandardError unless errors_hash.present? && errors_hash.is_a?(Hash) && errors_hash.keys.size == 1 errors_key = errors_hash.keys.first errors = errors_hash.values.flatten.first errors = errors.respond_to?(:to_h) ? errors.to_h : errors case errors when Hash sort_hash_errors(errors, errors_key) when Array sort_array_errors(errors, errors_key) when String sort_string_errors(errors, errors_key) else raise StandardError end end |