1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Rework Account to use delegated types

This commit is contained in:
Rob Zolkos 2024-02-02 23:09:35 +00:00
parent 938656de0e
commit 71939d6fb5
36 changed files with 282 additions and 0 deletions

View file

@ -3,5 +3,7 @@ class Account < ApplicationRecord
belongs_to :family
delegated_type :accountable, types: %w[ Credit Depository Investment Loan OtherAsset OtherLiability Property Vehicle]
scope :depository, -> { where(type: "Depository") }
end

View file

@ -0,0 +1,3 @@
class Account::Credit < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,3 @@
class Account::Depository < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,3 @@
class Account::Investment < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,3 @@
class Account::Loan < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,3 @@
class Account::OtherAsset < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,3 @@
class Account::OtherLiability < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,3 @@
class Account::Property < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,3 @@
class Account::Vehicle < ApplicationRecord
include Accountable
end

View file

@ -0,0 +1,7 @@
module Accountable
extend ActiveSupport::Concern
included do
has_one :account, as: :accountable, touch: true
end
end