Sha256: 82cfa369089d1c6d557787a64aa3f4481bf765da89bcb1dbb3f9b30a9fd26bb8

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 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)
    @processing_version
  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

1 entries across 1 versions & 1 rubygems

Version Path
pulitzer-0.4.7 app/interactions/pulitzer/update_version_status.rb