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.



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

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.



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

def action
  @action
end

Class Method Details

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



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

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



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

def call
  create_workflow_action!
  build_workflow_attributes
  build_strategy_state_entries
  build_transition_to_state
  build_email_generator
  build_action_methods
end