Sha256: 64a323285340d771bd6e215e3551795d8486f034353edeed3a7856185bbb0731

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require "grape-entity"

module RestFtpDaemon
  module Entities
    class Job < Grape::Entity

      # Some formatters
      format_with(:utf8_filter) do |thing|
        thing.to_s.encode("UTF-8") if thing
      end

      # Job-execution related
      expose :id
      expose :wid, unless: lambda { |object, _options| object.wid.nil? }

      # Attributes from API
      RestFtpDaemon::Job::IMPORTED.each do |field|
        expose field
      end

      # Work-specific options
      expose :overwrite
      expose :mkdir
      expose :tempfile
      expose :video_custom

      # Job/Video options
      expose :video_options
      #, using: Entities::VideoOptions

      # Status and error
      expose :status, format_with: :utf8_filter
      expose :error, format_with: :utf8_filter

      # Time stamps
      expose :queued_at
      expose :updated_at
      expose :started_at
      expose :finished_at

      # Computed fields
      expose :age           #, safe: true
      expose :exectime

      # Infos
      expose :infos, unless: :hide_infos

      # Source and target     #, :unless => Proc.new {|g| g.source_loc.nil?}
      expose :source_loc, using: Entities::Location#, as: :source
      expose :target_loc, using: Entities::Location#, as: :target

      # expose :slots do |station,options|
      #   station.slots.map{ |slot| SlotEntity.new(slot).serializable_hash }
      # end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.423.0 lib/rest-ftp-daemon/api/entities/job.rb