2019-08-14 09:48:44 +00:00
|
|
|
class ApplicationRecord < ActiveRecord::Base
|
2020-08-25 17:34:02 +00:00
|
|
|
include Events::Types
|
2019-08-14 09:48:44 +00:00
|
|
|
self.abstract_class = true
|
2020-08-25 17:34:02 +00:00
|
|
|
|
|
|
|
# the models that exposed in email templates through liquid
|
2021-08-18 09:58:45 +00:00
|
|
|
DROPPABLES = %w[Account Channel Conversation Inbox User Message].freeze
|
2020-08-06 09:51:06 +00:00
|
|
|
|
2020-08-25 17:34:02 +00:00
|
|
|
# ModelDrop class should exist in app/drops
|
2020-08-06 09:51:06 +00:00
|
|
|
def to_drop
|
|
|
|
return unless DROPPABLES.include?(self.class.name)
|
|
|
|
|
|
|
|
"#{self.class.name}Drop".constantize.new(self)
|
|
|
|
end
|
2022-09-22 21:08:48 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def normalize_empty_string_to_nil(attrs = [])
|
|
|
|
attrs.each do |attr|
|
|
|
|
self[attr] = nil if self[attr].blank?
|
|
|
|
end
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|