background_job.rb 722 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class Transaction::BackgroundJob
  3. def initialize(item, params = {})
  4. =begin
  5. {
  6. object: 'Ticket',
  7. type: 'update',
  8. ticket_id: 123,
  9. via_web: true,
  10. changes: {
  11. 'attribute1' => [before,now],
  12. 'attribute2' => [before,now],
  13. }
  14. },
  15. =end
  16. @item = item
  17. @params = params
  18. end
  19. def perform
  20. Setting.where(area: 'Transaction::Backend').order(:name).each {|setting|
  21. backend = Setting.get(setting.name)
  22. integration = Kernel.const_get(backend).new(@item, @params)
  23. integration.perform
  24. }
  25. end
  26. def self.run(item, params = {})
  27. generic = new(item, params)
  28. generic.perform
  29. end
  30. end