Sha256: 7587bcebbf1361020fe8d11774609ee406c289e7db9978aa1b26356c9f54979e

Contents?: true

Size: 870 Bytes

Versions: 31

Compression:

Stored size: 870 Bytes

Contents

module Bankserv
  
  class Document < ActiveRecord::Base
    self.inheritance_column = :_type_disabled
    
    belongs_to :set
    has_many :sets
    serialize :error
        
    def mark_processed!
      self.update_attributes!(processed: true)
    end
    
    def to_hash
      set.to_hash
    end
    
    def input?
      type == 'input'
    end
    
    def output?
      type == 'output'
    end
    
    def reply?
      type == 'reply'
    end
    
    def sets
      set.contained_sets
    end
    
    def records # unordered flat array records
      sets.map(&:records).flatten
    end
    
    def set_with_generation_number(generation_number)
      sets.select{|set| set.generation_number == generation_number}.first
    end


    def set_with_dept_code(dept_code)
      sets.select{|set| set.header.data[:dept_code] == dept_code}.first
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
bankserv-0.8.6 lib/bankserv/transmission/document.rb
bankserv-0.8.5 lib/bankserv/transmission/document.rb
bankserv-0.8.4 lib/bankserv/transmission/document.rb
bankserv-0.8.2 lib/bankserv/transmission/document.rb
bankserv-0.8.1 lib/bankserv/transmission/document.rb
bankserv-0.8.0 lib/bankserv/transmission/document.rb
bankserv-0.7.9 lib/bankserv/transmission/document.rb
bankserv-0.7.8 lib/bankserv/transmission/document.rb
bankserv-0.7.7 lib/bankserv/transmission/document.rb
bankserv-0.7.6 lib/bankserv/transmission/document.rb
bankserv-0.7.5 lib/bankserv/transmission/document.rb
bankserv-0.7.4 lib/bankserv/transmission/document.rb
bankserv-0.7.3 lib/bankserv/transmission/document.rb
bankserv-0.7.2 lib/bankserv/transmission/document.rb
bankserv-0.7.1 lib/bankserv/transmission/document.rb
bankserv-0.7.0 lib/bankserv/transmission/document.rb
bankserv-0.6.9 lib/bankserv/transmission/document.rb
bankserv-0.6.8 lib/bankserv/transmission/document.rb
bankserv-0.6.7 lib/bankserv/transmission/document.rb
bankserv-0.6.6 lib/bankserv/transmission/document.rb