Sha256: 9e1790f9ed059515f67ffaa8ca4fb32e64d23bff5f85fde442a883caca025793
Contents?: true
Size: 770 Bytes
Versions: 5
Compression:
Stored size: 770 Bytes
Contents
require 'aasm' module PuntoPagosRails class Transaction < ActiveRecord::Base include AASM belongs_to :payable, polymorphic: true after_save :persist_state_in_payable delegate :amount, to: :payable aasm column: :state do state :pending, initial: true state :completed state :rejected event :complete do transitions from: :pending, to: :completed end event :reject do transitions from: :pending, to: :rejected end end def reject_with(error) self.error = error reject! end def amount_to_s "%0.2f" % amount.to_i end def persist_state_in_payable return unless payable payable.update_column(:payment_state, state) end end end
Version data entries
5 entries across 5 versions & 1 rubygems