1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-30 11:24:21 +01:00
fab-manager/app/models/wallet.rb
2016-07-21 16:32:54 +02:00

25 lines
443 B
Ruby

class Wallet < ActiveRecord::Base
include AmountConcern
belongs_to :user
has_many :wallet_transactions, dependent: :destroy
validates :user, presence: true
def credit(amount)
if amount.is_a?(Numeric) and amount >= 0
self.amount += amount
return save
end
false
end
def debit(amount)
if amount.is_a?(Numeric) and amount >= 0
self.amount -= amount
return save
end
false
end
end