Module: WalletAccessor

Defined in:
app/accessors/wallet_accessor.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/accessors/wallet_accessor.rb', line 2

def self.included(base)
  base.class_eval do
    belongs_to :bank_account
    belongs_to :investor_account
    alias_method :investor, :investor_account
    belongs_to :currency
    has_many :top_ups, dependent: :destroy
    has_many :withdrawals, dependent: :destroy
    has_many :journal_entries, dependent: :destroy
    has_many :investments, dependent: :destroy, class_name: investment_klass.to_s

    scope :idr, ->{ joins(:currency).where('currencies.code' => 'IDR') }
    scope :sgd, ->{ joins(:currency).where('currencies.code' => 'SGD') }
    scope :myr, ->{ joins(:currency).where('currencies.code' => 'MYR') }
  end
end