I've a class defined as such:
class PublicationJob < ActiveJob::Base
def self.jobs
@jobs ||= Hash{|h, k| h[k] = []}
end
def self.register(format, job_class)
jobs[format] << job_class
end
# [...]
end
To register different job classes, I put in an initializer:
PublicationJob.register(:tex, SaveJob)
PublicationJob.register(:saved_tex, TexJob)
#...
The in the rails console
I try:
PublicationJob.jobs
#> {:tex => [SaveJob], :saved_tex => [TexJob]}
But if I exit the console (Ctrl-D) then restart it, at some point the hash will be empty!
Why is the class variable reset in this case?
I use rails 4.2.1 and spring, and I know that if I kill/stop spring it works again for some time. Is it related to spring?