Files
sure/app/models/account.rb
2024-02-03 02:50:09 +00:00

15 lines
520 B
Ruby

class Account < ApplicationRecord
belongs_to :family
delegated_type :accountable, types: %w[ Account::Credit Account::Depository Account::Investment Account::Loan Account::OtherAsset Account::OtherLiability Account::Property Account::Vehicle], dependent: :destroy
delegate :icon, :type_name, :color, to: :accountable
# Class method to get a representative instance of each accountable type
def self.accountable_type_instances
accountable_types.map do |type|
type.constantize.new
end
end
end