Module: RocketJob::Category::Base

Extended by:
ActiveSupport::Concern
Included in:
Input, Output
Defined in:
lib/rocket_job/category/base.rb

Overview

Define the layout for each category of input or output data

Instance Method Summary collapse

Instance Method Details

#build_collection_name(direction, job) ⇒ Object



74
75
76
77
78
# File 'lib/rocket_job/category/base.rb', line 74

def build_collection_name(direction, job)
  collection_name = "rocket_job.#{direction}s.#{job.id}"
  collection_name << ".#{name}" unless name == :main
  collection_name
end

#serializer_classObject

Return which slice serializer class to use that matches the current options.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rocket_job/category/base.rb', line 43

def serializer_class
  case serializer
  when :none
    Sliced::Slice
  when :compress
    Sliced::CompressedSlice
  when :encrypt
    Sliced::EncryptedSlice
  when :bzip2, :bz2
    Sliced::BZip2OutputSlice
  when :encrypted_bz2
    Sliced::EncryptedBZip2OutputSlice
  else
    raise(ArgumentError, "serialize: #{serializer.inspect} must be :none, :compress, :encrypt, :bz2, or :encrypted_bz2")
  end
end

#tabularObject



60
61
62
63
64
65
66
67
# File 'lib/rocket_job/category/base.rb', line 60

def tabular
  @tabular ||= IOStreams::Tabular.new(
    columns:        columns,
    format:         format == :auto ? nil : format,
    format_options: format_options&.to_h&.deep_symbolize_keys,
    file_name:      file_name
  )
end

#tabular?Boolean

Returns [true|false] whether this category has the attributes defined for tabular to work.

Returns:

  • (Boolean)


70
71
72
# File 'lib/rocket_job/category/base.rb', line 70

def tabular?
  format.present?
end