mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
* Fix accountable type references in new account flow * Add remaining references * Refactor accountable type checking * Refactor new account template to use account * Refactor account create action * Refactor account sidebar
18 lines
506 B
Ruby
18 lines
506 B
Ruby
module Accountable
|
|
extend ActiveSupport::Concern
|
|
|
|
TYPES = %w[ Account::Credit Account::Depository Account::Investment Account::Loan Account::OtherAsset Account::OtherLiability Account::Property Account::Vehicle ]
|
|
|
|
def self.from_type(type)
|
|
return nil unless types.include?(type) || TYPES.include?(type)
|
|
"Account::#{type.demodulize}".constantize
|
|
end
|
|
|
|
def self.types
|
|
TYPES.map { |type| type.demodulize }
|
|
end
|
|
|
|
included do
|
|
has_one :account, as: :accountable, touch: true
|
|
end
|
|
end
|