2024-03-20 16:37:21 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
#
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: account_relationship_severance_events
|
|
|
|
#
|
|
|
|
# id :bigint(8) not null, primary key
|
|
|
|
# account_id :bigint(8) not null
|
|
|
|
# relationship_severance_event_id :bigint(8) not null
|
2024-03-20 17:08:34 +01:00
|
|
|
# relationships_count :integer default(0), not null
|
2024-03-20 16:37:21 +01:00
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
#
|
|
|
|
class AccountRelationshipSeveranceEvent < ApplicationRecord
|
|
|
|
belongs_to :account
|
|
|
|
belongs_to :relationship_severance_event
|
|
|
|
|
2024-03-20 18:02:09 +01:00
|
|
|
delegate :severed_relationships, :type, :target_name, :purged?, to: :relationship_severance_event, prefix: false
|
2024-03-20 16:37:21 +01:00
|
|
|
|
|
|
|
before_create :set_relationships_count!
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_relationships_count!
|
|
|
|
self.relationships_count = severed_relationships.where(local_account: account).count
|
|
|
|
end
|
|
|
|
end
|