2024-02-02 09:05:04 -06:00
|
|
|
class Account < ApplicationRecord
|
|
|
|
belongs_to :family
|
2024-02-02 11:09:31 -06:00
|
|
|
|
2024-02-02 23:06:29 +00:00
|
|
|
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
|
2024-02-02 23:09:35 +00:00
|
|
|
|
2024-02-02 23:06:29 +00:00
|
|
|
# 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
|
2024-02-02 09:05:04 -06:00
|
|
|
end
|