Sha256: 921d20a7a2b5d6ea81893f7842252bfe1495958e47b4fbe8b83e5717ab72ad37

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

class Pulitzer::UpdateVersionStatus
  def initialize(version, status)
    @transitional_version = version
    @status = status
    @status_change_method = 'make_version_' + @status.to_s
    @post = version.post
  end

  def call
    send @status_change_method
  end

  def make_version_active
    @new_active_version = @transitional_version
    @old_active_version = @new_active_version.post.active_version
    @new_active_version.update(status: :active)
    @new_active_version.tags.each &:touch
    @old_active_version.update(status: :archived) if @old_active_version
    @processing_version = @post.create_processing_version
    Pulitzer::CloneVersionJob.perform_later(@new_active_version)
    @post.reload
    @processing_version.reload
  end

  def make_version_abandoned
    @active_version = @transitional_version.post.active_version
    @transitional_version.update(status: :abandoned)
    if @active_version == @transitional_version
      @transitional_version.post.preview_version
    else
      @processing_version = @post.create_processing_version
      Pulitzer::CloneVersionJob.perform_later(@active_version)
      @processing_version
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pulitzer-0.4.12 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.11 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.10 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.9 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.8 app/interactions/pulitzer/update_version_status.rb