Class: Users::CreditCardValidation

Inherits:
ApplicationRecord show all
Defined in:
app/models/users/credit_card_validation.rb

Constant Summary collapse

RELEASE_DAY =
Date.new(2021, 5, 17)

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Method Details

#set_expiration_date_hashObject



70
71
72
# File 'app/models/users/credit_card_validation.rb', line 70

def set_expiration_date_hash
  self.expiration_date_hash = Gitlab::CryptoHelper.sha256(expiration_date.to_s)
end

#set_holder_name_hashObject



62
63
64
# File 'app/models/users/credit_card_validation.rb', line 62

def set_holder_name_hash
  self.holder_name_hash = Gitlab::CryptoHelper.sha256(holder_name.downcase)
end

#set_last_digits_hashObject



58
59
60
# File 'app/models/users/credit_card_validation.rb', line 58

def set_last_digits_hash
  self.last_digits_hash = Gitlab::CryptoHelper.sha256(last_digits)
end

#set_network_hashObject



66
67
68
# File 'app/models/users/credit_card_validation.rb', line 66

def set_network_hash
  self.network_hash = Gitlab::CryptoHelper.sha256(network.downcase)
end

#similar_holder_names_countObject



50
51
52
# File 'app/models/users/credit_card_validation.rb', line 50

def similar_holder_names_count
  self.class.similar_by_holder_name(holder_name).count
end

#similar_recordsObject



46
47
48
# File 'app/models/users/credit_card_validation.rb', line 46

def similar_records
  self.class.similar_to(self).order(credit_card_validated_at: :desc).includes(:user)
end

#used_by_banned_user?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/models/users/credit_card_validation.rb', line 54

def used_by_banned_user?
  self.class.by_banned_user.similar_to(self).similar_by_holder_name(holder_name).exists?
end