AyuntamientoMadrid/participacion

View on GitHub
app/models/verified_user.rb

Summary

Maintainability
A
0 mins
Test Coverage
class VerifiedUser < ApplicationRecord
  scope :by_user,  ->(user)  { where(document_number: user.document_number) }

  scope :by_email, ->(email) { where(email: email) }
  scope :by_phone, ->(phone) { where(phone: phone) }

  def self.phone?(user)
    by_user(user).by_phone(user.unconfirmed_phone).first.present?
  end
end