Sha256: 2960bb765dd09dbf100bda6e00d954cbbcb3def9bad64c7e6b2419d688369185

Contents?: true

Size: 981 Bytes

Versions: 8

Compression:

Stored size: 981 Bytes

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)
    @processing_version = @post.create_processing_version
    Pulitzer::CloneVersionJob.perform_later(@active_version)
    @processing_version
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pulitzer-0.3.7 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.6 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.5 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.4 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.3 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.2 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.1 app/interactions/pulitzer/update_version_status.rb
pulitzer-0.3.0 app/interactions/pulitzer/update_version_status.rb