module Subledger::Domain::Roles::Postable
Public Instance Methods
post()
click to toggle source
# File lib/subledger/domain/roles/postable.rb, line 5 def post validate_postability from_db = read from_store = store.post self if from_db.kind_of? posted_klass from_db else from_store end end
posted_klass()
click to toggle source
# File lib/subledger/domain/roles/postable.rb, line 23 def posted_klass PostedJournalEntry end
posting_klass()
click to toggle source
# File lib/subledger/domain/roles/postable.rb, line 19 def posting_klass PostingJournalEntry end
Private Instance Methods
validate_postability()
click to toggle source
# File lib/subledger/domain/roles/postable.rb, line 29 def validate_postability case self when ArchivedJournalEntry raise PostableError, 'Cannot post an archived journal entry' when ActiveJournalEntry reason = if lines.length.zero? 'Cannot post a journal entry with no lines' elsif not balanced? 'Cannot post an unbalanced journal entry' end unless reason.nil? set_reason reason raise PostableError, reason end when PostingJournalEntry # All is fine when PostedJournalEntry # All is fine end end