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:
parent
938656de0e
commit
71939d6fb5
36 changed files with 282 additions and 0 deletions
|
@ -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
|
||||
|
|
3
app/models/account/credit.rb
Normal file
3
app/models/account/credit.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::Credit < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
3
app/models/account/depository.rb
Normal file
3
app/models/account/depository.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::Depository < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
3
app/models/account/investment.rb
Normal file
3
app/models/account/investment.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::Investment < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
3
app/models/account/loan.rb
Normal file
3
app/models/account/loan.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::Loan < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
3
app/models/account/other_asset.rb
Normal file
3
app/models/account/other_asset.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::OtherAsset < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
3
app/models/account/other_liability.rb
Normal file
3
app/models/account/other_liability.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::OtherLiability < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
3
app/models/account/property.rb
Normal file
3
app/models/account/property.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::Property < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
3
app/models/account/vehicle.rb
Normal file
3
app/models/account/vehicle.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Account::Vehicle < ApplicationRecord
|
||||
include Accountable
|
||||
end
|
7
app/models/concerns/accountable.rb
Normal file
7
app/models/concerns/accountable.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
module Accountable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_one :account, as: :accountable, touch: true
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue