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



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

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.



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

def activejob_enabled
  @activejob_enabled
end

#assignment_byObject



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

def assignment_by
  @assignment_by || @default_assignment_by
end

#import_preprocessorObject



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

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

#operation_typesObject

Returns the value of attribute operation_types.



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

def operation_types
  @operation_types
end

#process_classObject



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

def process_class
  @process_class || @default_process_class
end

#sql_dialectObject



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

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



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

def default_operation_template_type
  @operation_template_type || @default_operation_template_type
end

#manager_classObject



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

def manager_class
  @process_manager || @default_process_manager
end

#manager_class=(value) ⇒ Object



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

def manager_class=(value)
  @process_manager = value
end

#operation_template_klass=(value) ⇒ Object

TODO: fix



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

def operation_template_klass=(value)
  @operation_template_type = value
end

#process_managerObject



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

def process_manager
  # Todo add custom managers support
  ProcessManager
end

#process_template_klass=(value) ⇒ Object



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

def process_template_klass=(value)
  @process_template_type = value
end

#process_template_typeObject



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

def process_template_type
  @process_template_type || @default_process_template_type
end