Sha256: dc738f63f273e3769c5c8de9a3f72805056c8beaeda58fef3123b97f21803de5

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

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

9 entries across 9 versions & 1 rubygems

Version Path
pulitzer-0.4.6 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.5 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.4 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.3 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.2 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.1 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.4.0 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.9 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.8 app/interactions/pulitzer/update_version_status.rb