Sha256: b3858ed36358b292ab8822ca6ecbb893a8aa64154dc7faacec1e7b7efdca7025

Contents?: true

Size: 1.38 KB

Versions: 4

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

      # Job/Video options
      expose :video_options
      expose :video_custom

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

      # Time stamps
      expose :created_at
      expose :created_since       #, safe: true

      expose :started_at
      expose :started_since

      expose :finished_at
      expose :finished_in

      expose :updated_at

      # 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

4 entries across 4 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.435.2 lib/rest-ftp-daemon/entities/job.rb
rest-ftp-daemon-0.435.1 lib/rest-ftp-daemon/entities/job.rb
rest-ftp-daemon-0.435.0 lib/rest-ftp-daemon/entities/job.rb
rest-ftp-daemon-0.434.0 lib/rest-ftp-daemon/entities/job.rb