Class: Lcms::Engine::DocumentGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/services/lcms/engine/document_generator.rb

Constant Summary collapse

CONTENT_TYPES =
%w(full tm sm).freeze
DOCUMENT_GENERATORS =
{
  gdoc: '::Lcms::Engine::DocumentGenerateGdocJob',
  pdf: '::Lcms::Engine::DocumentGeneratePdfJob'
}.with_indifferent_access.freeze
DOCUMENT_PARSE_JOB =
'::Lcms::Engine::DocumentParseJob'
DOCUMENT_PRESENTER =
'::Lcms::Engine::DocumentPresenter'
MATERIAL_GENERATORS =
{
  gdoc: '::Lcms::Engine::MaterialGenerateGdocJob',
  pdf: '::Lcms::Engine::MaterialGeneratePdfJob'
}.with_indifferent_access.freeze
MATERIAL_PARSE_JOB =
'::Lcms::Engine::MaterialParseJob'
MATERIAL_PRESENTER =
'::Lcms::Engine::MaterialPresenter'

Class Method Summary collapse

Class Method Details

.document_generatorsObject



32
33
34
# File 'app/services/lcms/engine/document_generator.rb', line 32

def document_generators
  @document_generators ||= DOCUMENT_GENERATORS.slice(*DocTemplate.document_contexts).values
end

.document_parse_jobObject



36
37
38
39
40
41
42
# File 'app/services/lcms/engine/document_generator.rb', line 36

def document_parse_job
  @document_parse_job ||=
    begin
      klass = DocTemplate.config['document_parse_job'].presence || DOCUMENT_PARSE_JOB
      klass.constantize
    end
end

.document_presenterObject



44
45
46
47
48
49
50
# File 'app/services/lcms/engine/document_generator.rb', line 44

def document_presenter
  @document_presenter ||=
    begin
      klass = DocTemplate.config['document_presenter'].presence || DOCUMENT_PRESENTER
      klass.constantize
    end
end

.generate_for(document) ⇒ Object



25
26
27
28
29
30
# File 'app/services/lcms/engine/document_generator.rb', line 25

def generate_for(document)
  return material_preview_job&.perform_later(document) if document.is_a?(Lcms::Engine::Material)

  reset_links document
  Lcms::Engine::DocumentGenerateJob.perform_later(document)
end

.material_formObject



56
57
58
# File 'app/services/lcms/engine/document_generator.rb', line 56

def material_form
  @material_form ||= DocTemplate.config['material_form']&.constantize || ::Lcms::Engine::MaterialForm
end

.material_generatorsObject



52
53
54
# File 'app/services/lcms/engine/document_generator.rb', line 52

def material_generators
  @material_generators ||= MATERIAL_GENERATORS.slice(*DocTemplate.material_contexts).values
end

.material_parse_jobObject



60
61
62
63
64
65
66
# File 'app/services/lcms/engine/document_generator.rb', line 60

def material_parse_job
  @material_parse_job ||=
    begin
      klass = DocTemplate.config['material_parse_job'].presence || MATERIAL_PARSE_JOB
      klass.constantize
    end
end

.material_presenterObject



68
69
70
71
72
73
74
# File 'app/services/lcms/engine/document_generator.rb', line 68

def material_presenter
  @material_presenter ||=
    begin
      klass = DocTemplate.config['material_presenter'].presence || MATERIAL_PRESENTER
      klass.constantize
    end
end