Class: Tartarus::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/tartarus/repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(backend: Sidekiq::Cron::Job, serializer: Tartarus::ArchivableItem::SidekiqCronJobSerializer.new) ⇒ Repository

Returns a new instance of Repository.



5
6
7
8
# File 'lib/tartarus/repository.rb', line 5

def initialize(backend: Sidekiq::Cron::Job, serializer: Tartarus::ArchivableItem::SidekiqCronJobSerializer.new)
  @backend = backend
  @serializer = serializer
end

Instance Method Details

#save(archivable_item) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/tartarus/repository.rb', line 10

def save(archivable_item)
  backend.new(serializer.serialize(archivable_item)).tap do |job|
    if job.valid?
      job.save
    else
      raise_invalid_job(job)
    end
  end
end