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.25 app/services/workarea/save_publishing.rb
workarea-core-3.4.24 app/services/workarea/save_publishing.rb
workarea-core-3.4.23 app/services/workarea/save_publishing.rb
workarea-core-3.4.22 app/services/workarea/save_publishing.rb
workarea-core-3.4.21 app/services/workarea/save_publishing.rb
workarea-core-3.4.20 app/services/workarea/save_publishing.rb
workarea-core-3.4.19 app/services/workarea/save_publishing.rb
workarea-core-3.4.18 app/services/workarea/save_publishing.rb
workarea-core-3.4.17 app/services/workarea/save_publishing.rb
workarea-core-3.4.16 app/services/workarea/save_publishing.rb
workarea-core-3.4.15 app/services/workarea/save_publishing.rb
workarea-core-3.4.14 app/services/workarea/save_publishing.rb
workarea-core-3.4.13 app/services/workarea/save_publishing.rb
workarea-core-3.4.12 app/services/workarea/save_publishing.rb