Class: Hyrax::Workflow::WorkflowFactory

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

Overview

Responsible for:

  • Creating a Sipity::Entity (aka a database proxy for the given work)

  • Assigning specific roles to the Sipity::Entity (but not the workflow)

  • Running the deposit_action

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work, attributes, user) ⇒ WorkflowFactory

Returns a new instance of WorkflowFactory.

Parameters:

  • work (#to_global_id, #admin_set_id)
  • user (User)
  • attributes (Hash)

30
31
32
33
34
# File 'app/services/hyrax/workflow/workflow_factory.rb', line 30

def initialize(work, attributes, user)
  @work = work
  @attributes = attributes
  @user = user
end

Class Method Details

.create(work, attributes, user) ⇒ TrueClass

Parameters:

  • work (#to_global_id)
  • attributes (Hash)
  • user (User)

Returns:

  • (TrueClass)

23
24
25
# File 'app/services/hyrax/workflow/workflow_factory.rb', line 23

def self.create(work, attributes, user)
  new(work, attributes, user).create
end

Instance Method Details

#createTrueClass

Creates a Sipity::Entity for the work. The Sipity::Entity acts as a proxy to a work within a workflow

Returns:

  • (TrueClass)

42
43
44
45
46
47
48
# File 'app/services/hyrax/workflow/workflow_factory.rb', line 42

def create
  action = find_deposit_action
  entity = create_workflow_entity!
  assign_specific_roles_to(entity: entity)
  run_workflow_action!(action: action)
  true
end