Add email checking with validation event saving

This commit is contained in:
Alex Sherman 2021-06-29 16:13:40 +05:00
parent d4fe961e34
commit c344b91d84
4 changed files with 65 additions and 4 deletions

View file

@ -1,9 +1,17 @@
class ValidationEvent < ActiveRecord::Base
# frozen_string_literal: true
# Class to store validation events. Need to include boolean `success` field - was validation event
# successful or not.
# Types of events supported so far stored in ValidationEvent::EventType::TYPES
# For email_validation event kind also check_level (regex/mx/smtp) is stored in the event_data
class ValidationEvent < ApplicationRecord
enum event_type: ValidationEvent::EventType::TYPES, _suffix: true
store_accessor :event_data, :errors, :check_level, :email
belongs_to :validation_eventable, polymorphic: true
def event_type
@event_type ||= ValidationEvent::EventType.new(read_attribute(:event_kind))
@event_type ||= ValidationEvent::EventType.new(self[:event_kind])
end
end