Sha256: 02958483cb8dfaa0eafa6f79d4f0382630ad0425a981d44bbb732fe406559813

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

# encoding: UTF-8
#/* - - - - - - - - - - - - - - - - - - - - -
#
#   Title : WEB Appliances Crest Inc, Web Form Framework
#   Author : Enrique Phillips
#   URL : http://www.wac.bz
#
#- - - - - - - - - - - - - - - - - - - - - */

require 'print_drivers'

# The <b>PrintJob</b> model holds all relevant information in regards to the PrintJob
# It is possible to create a PrintJob for any other model that needs to be able to print.
class OxPrintJob < AbstractResource
  self.table_name = 'print_jobs'
  establish_connection ((Rails.env=="development") ? :dev_oxen_tables : :oxen_tables )

  has_paper_trail

  validates :name, presence: true

  belongs_to :printer
  belongs_to :account
  belongs_to :printed_by, polymorphic: true

  include Exceptions
  include PrintDrivers

  # has_paper_trail :ignore => [:state, :cups_state]

  scope :stated, ->(pap) { where(state: pap) }
  scope :queued, ->{ where(print_jobs.state >> ['processing','printing']) }

  # Temporary attribute for the print_job object to hold the instanciated printer (PdfPrinter, HtmlPrinter, CsvPrinter etc.)
  attr_accessor :action_printer, :snap_shot, :download

  #
  # enabling background printing - via OxJob & ActiveJob & DelayedJob
  def perform *args
    context = args[0].delete(:context)
    if !download
      print_with rendered_on(args)
    else
      send_with( rendered_on(args), context) if context
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
oxen_printer-0.2.8 app/models/ox_print_job.rb
oxen_printer-0.2.4 app/models/ox_print_job.rb
oxen_printer-0.2.1 app/models/ox_print_job.rb
oxen_printer-0.0.3 app/models/ox_print_job.rb