Sha256: 4f989e8b25a036b22d2d2c5529bd2fe0f1cd9dd42b0f00cacec017f54f1027d0

Contents?: true

Size: 760 Bytes

Versions: 15

Compression:

Stored size: 760 Bytes

Contents

module Shipit
  class TailTaskSerializer < ActiveModel::Serializer
    include ChunksHelper
    include ConditionalAttributes

    attributes :url, :status, :output, :rollback_url

    def url
      return @url if defined? @url
      @url = next_chunks_url(task)
    end

    def include_url?
      url.present?
    end

    def output
      task.chunks.tail(context[:last_id]).pluck(:text).join
    end

    def rollback_url
      stack_deploy_path(stack, rollback)
    end

    def include_rollback_url?
      !rollback.nil?
    end

    private

    alias_method :task, :object
    delegate :stack, to: :object

    def rollback
      return @rollback if defined? @rollback
      @rollback = stack.rollbacks.where(parent_id: task.id).last
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.30.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.29.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.28.1 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.28.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.27.1 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.27.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.26.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.25.1 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.25.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.24.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.23.1 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.23.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.22.0 app/serializers/shipit/tail_task_serializer.rb
shipit-engine-0.21.0 app/serializers/shipit/tail_task_serializer.rb