Class: RailsWorkflow::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rails_workflow/config.rb

Overview

Engine configuration. Allows to set default or custom classes and other engine settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

rubocop: disable Metrics/MethodLength



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rails_workflow/config.rb', line 32

def initialize # rubocop: disable Metrics/MethodLength
  init_default_operation_types
  # TODO: rework
  @default_assignment_by = %i[group role]

  @default_import_preprocessor =
    'RailsWorkflow::DefaultImporterPreprocessor'
  @default_operation_template_type = 'RailsWorkflow::OperationTemplate'
  @default_process_manager = 'RailsWorkflow::ProcessManager'
  @default_process_builder = 'RailsWorkflow::ProcessBuilder'
  @default_operation_builder = 'RailsWorkflow::OperationBuilder'
  @default_error_builder = 'RailsWorkflow::ErrorBuilder'
  @default_error_resolver = 'RailsWorkflow::ErrorResolver'
  @default_process_class = 'RailsWorkflow::Process'
  @default_process_template_type = 'RailsWorkflow::ProcessTemplate'

  @default_sql_dialect = 'pg'
  @default_process_runner = 'RailsWorkflow::ProcessRunner'
  @default_operation_runner = 'RailsWorkflow::OperationRunner'
  @default_dependency_resolver = 'RailsWorkflow::DependencyResolver'
end

Instance Attribute Details

#activejob_enabledObject

Returns the value of attribute activejob_enabled.



30
31
32
# File 'lib/rails_workflow/config.rb', line 30

def activejob_enabled
  @activejob_enabled
end

#assignment_byObject



67
68
69
# File 'lib/rails_workflow/config.rb', line 67

def assignment_by
  @assignment_by || @default_assignment_by
end

#import_preprocessorObject



82
83
84
85
# File 'lib/rails_workflow/config.rb', line 82

def import_preprocessor
  processor = @import_preprocessor || @default_import_preprocessor
  processor.constantize.new
end

#operation_typesObject

Returns the value of attribute operation_types.



29
30
31
# File 'lib/rails_workflow/config.rb', line 29

def operation_types
  @operation_types
end

#process_classObject



105
106
107
# File 'lib/rails_workflow/config.rb', line 105

def process_class
  @process_class || @default_process_class
end

#sql_dialectObject



57
58
59
60
61
62
63
64
# File 'lib/rails_workflow/config.rb', line 57

def sql_dialect
  case @sql_dialect || @default_sql_dialect
  when 'pg'
    RailsWorkflow::Db::Pg
  when 'mysql'
    RailsWorkflow::Db::Mysql
  end
end

Instance Method Details

#default_operation_template_typeObject



87
88
89
# File 'lib/rails_workflow/config.rb', line 87

def default_operation_template_type
  @operation_template_type || @default_operation_template_type
end

#manager_classObject



95
96
97
# File 'lib/rails_workflow/config.rb', line 95

def manager_class
  @process_manager || @default_process_manager
end

#manager_class=(value) ⇒ Object



91
92
93
# File 'lib/rails_workflow/config.rb', line 91

def manager_class=(value)
  @process_manager = value
end

#operation_template_klass=(value) ⇒ Object

TODO: fix



76
77
78
# File 'lib/rails_workflow/config.rb', line 76

def operation_template_klass=(value)
  @operation_template_type = value
end

#process_managerObject



113
114
115
116
# File 'lib/rails_workflow/config.rb', line 113

def process_manager
  # Todo add custom managers support
  ProcessManager
end

#process_template_klass=(value) ⇒ Object



101
102
103
# File 'lib/rails_workflow/config.rb', line 101

def process_template_klass=(value)
  @process_template_type = value
end

#process_template_typeObject



109
110
111
# File 'lib/rails_workflow/config.rb', line 109

def process_template_type
  @process_template_type || @default_process_template_type
end