Sha256: 921b93bd574284ed9cdc7927582577f5ba1fda5f53037cb7d42bc42a70120436

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

module RocketJob
  module Category
    # Define the layout for each category of input or output data
    class Output
      include SemanticLogger::Loggable
      include Plugins::Document
      include Category::Base

      embedded_in :job, class_name: "RocketJob::Job", inverse_of: :output_categories

      # Whether to skip nil values returned from the `perform` method.
      #   true: save nil values to the output categories.
      #   false: do not save nil values to the output categories.
      field :nils, type: ::Mongoid::Boolean, default: false

      validates_inclusion_of :serializer, in: %i[none compress encrypt bz2 encrypted_bz2 bzip2]

      # Renders [String] the header line.
      # Returns [nil] if no header is needed.
      def render_header
        return if !tabular? || !tabular.requires_header?

        tabular.render_header
      end

      def data_store(job)
        RocketJob::Sliced::Output.new(
          collection_name: build_collection_name(:output, job),
          slice_class:     serializer_class
        )
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rocketjob-6.3.1 lib/rocket_job/category/output.rb
rocketjob-6.3.0 lib/rocket_job/category/output.rb
rocketjob-6.2.0 lib/rocket_job/category/output.rb
rocketjob-6.1.1 lib/rocket_job/category/output.rb
rocketjob-6.1.0 lib/rocket_job/category/output.rb
rocketjob-6.0.3 lib/rocket_job/category/output.rb
rocketjob-6.0.2 lib/rocket_job/category/output.rb
rocketjob-6.0.1 lib/rocket_job/category/output.rb
rocketjob-6.0.0 lib/rocket_job/category/output.rb