1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-27 17:19:39 +02:00
Maybe/app/models/concerns/accountable.rb

19 lines
506 B
Ruby
Raw Normal View History

2024-02-02 23:09:35 +00:00
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
2024-02-02 23:09:35 +00:00
included do
has_one :account, as: :accountable, touch: true
end
end