base.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. module Import
  3. class Base
  4. # Checks if the backend is able to get queued by the Scheduler.
  5. #
  6. # @example
  7. # Import::ExampleBackend.queueable?
  8. # #=> true
  9. #
  10. # return [Boolean]
  11. def self.queueable?
  12. true
  13. end
  14. # Checks if the backend is able to get rescheduled in case the Scheduler
  15. # got (re-)started while this ImportJob was running. Defaults to false.
  16. #
  17. # @example
  18. # instance = Import::LDAP.new(import_job)
  19. # instance.reschedule?(delayed_job)
  20. # #=> false
  21. #
  22. # return [false]
  23. def reschedule?(_delayed_job)
  24. false
  25. end
  26. # Initializes a new instance with a stored reference to the ImportJob.
  27. #
  28. # @example
  29. # instance = Import::ExampleBackend.new(import_job)
  30. #
  31. # return [Import::ExampleBackend]
  32. def initialize(import_job)
  33. @import_job = import_job
  34. end
  35. # Starts the life or dry run import of the backend.
  36. #
  37. # @example
  38. # instance = Import::ExampleBackend.new(import_job)
  39. #
  40. # @raise [RuntimeError] Raised if the implementation of this mandatory method is missing
  41. #
  42. # return [nil]
  43. def start
  44. raise "Missing implementation if the 'start' method."
  45. end
  46. end
  47. end