Class: Hyrax::Workflow::StateMachineGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/workflow/state_machine_generator.rb

Overview

Imports a single action for a workflow, including all of the adjacent states, permissions and notifications

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow:, action_name:, config:, email_generator_method_name: :schema_based_email_generator_method) ⇒ StateMachineGenerator

Returns a new instance of StateMachineGenerator.



14
15
16
17
18
19
# File 'app/services/hyrax/workflow/state_machine_generator.rb', line 14

def initialize(workflow:, action_name:, config:, email_generator_method_name: :schema_based_email_generator_method)
  self.workflow = workflow
  self.action_name = action_name
  self.config = config
  self.email_generator_method_name = email_generator_method_name
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



31
32
33
# File 'app/services/hyrax/workflow/state_machine_generator.rb', line 31

def action
  @action
end

Class Method Details

.generate_from_schema(workflow:, name:, **keywords) ⇒ Object



7
8
9
10
11
12
# File 'app/services/hyrax/workflow/state_machine_generator.rb', line 7

def self.generate_from_schema(workflow:, name:, **keywords)
  new(
    workflow: workflow, action_name: name, config: keywords,
    email_generator_method_name: :schema_based_email_generator_method
  ).call
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
# File 'app/services/hyrax/workflow/state_machine_generator.rb', line 33

def call
  create_workflow_action!
  build_workflow_attributes
  build_strategy_state_entries
  build_transition_to_state
  build_email_generator
  build_action_methods
end