Module: ErpTxnsAndAccts::Extensions::ActiveRecord::ActsAsBizTxnEvent::InstanceMethods

Defined in:
lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb

Instance Method Summary collapse

Instance Method Details

#account=(acct) ⇒ Object

allow for a client to pass either an account root or a polymorphic subclass of account root, but always set the account to the root



61
62
63
64
65
66
67
# File 'lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb', line 61

def account=(acct)
  if acct.instance_of?(BizTxnAcctRoot)
    self.biz_txn_event.biz_txn_acct_root = (acct)
  else
    self.biz_txn_event.biz_txn_acct_root = (acct.biz_txn_acct_root)
  end
end

#destroy_biz_txn_event ⇒ Object



81
82
83
# File 'lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb', line 81

def destroy_biz_txn_event
  self.biz_txn_event.destroy if (self.biz_txn_event && !self.biz_txn_event.frozen?)
end

#initialize_biz_txn_event ⇒ Object



73
74
75
76
77
78
79
# File 'lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb', line 73

def initialize_biz_txn_event
  if self.new_record? and self.biz_txn_event.nil?
    t = BizTxnEvent.new
    self.biz_txn_event = t
    t.biz_txn_record = self
  end
end

#root_txn ⇒ Object



55
56
57
# File 'lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb', line 55

def root_txn
  self.biz_txn_event
end

#save_biz_txn_event ⇒ Object



69
70
71
# File 'lib/erp_txns_and_accts/extensions/active_record/acts_as_biz_txn_event.rb', line 69

def save_biz_txn_event
  self.biz_txn_event.save
end