Sha256: df1781aede924be70f2fd25673219659d57d7399ce2cba045c77195676d38c64

Contents?: true

Size: 764 Bytes

Versions: 34

Compression:

Stored size: 764 Bytes

Contents

module Workarea
  class SavePublishing
    delegate :errors, to: :release, allow_nil: true

    def initialize(releasable, params)
      @releasable = releasable
      @params = params
    end

    def perform
      return false if release.present? && !release.valid?
      return true if @releasable.blank?

      Release.with_current(release.try(:id)) do
        @releasable.update_attributes!(active: activate?)
      end
    end

    def release
      return if @params[:activate].in?(%w(now never))

      @release ||=
        if @params[:activate] == 'new_release'
          Release.create(@params[:release])
        else
          Release.find(@params[:activate])
        end
    end

    def activate?
      @params[:activate] != 'never'
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/services/workarea/save_publishing.rb
workarea-core-3.4.44 app/services/workarea/save_publishing.rb
workarea-core-3.4.43 app/services/workarea/save_publishing.rb
workarea-core-3.4.42 app/services/workarea/save_publishing.rb
workarea-core-3.4.41 app/services/workarea/save_publishing.rb
workarea-core-3.4.40 app/services/workarea/save_publishing.rb
workarea-core-3.4.39 app/services/workarea/save_publishing.rb
workarea-core-3.4.38 app/services/workarea/save_publishing.rb
workarea-core-3.4.37 app/services/workarea/save_publishing.rb
workarea-core-3.4.36 app/services/workarea/save_publishing.rb
workarea-core-3.4.35 app/services/workarea/save_publishing.rb
workarea-core-3.4.34 app/services/workarea/save_publishing.rb
workarea-core-3.4.33 app/services/workarea/save_publishing.rb
workarea-core-3.4.32 app/services/workarea/save_publishing.rb
workarea-core-3.4.31 app/services/workarea/save_publishing.rb
workarea-core-3.4.30 app/services/workarea/save_publishing.rb
workarea-core-3.4.29 app/services/workarea/save_publishing.rb
workarea-core-3.4.28 app/services/workarea/save_publishing.rb
workarea-core-3.4.27 app/services/workarea/save_publishing.rb
workarea-core-3.4.26 app/services/workarea/save_publishing.rb