Class: Hyrax::Workflow::ActionableObjects

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
app/services/hyrax/workflow/actionable_objects.rb

Overview

Produces a list of workflow-ready objects for a given user. Results are given as a presenter objects with SolrDocument-like behavior, with added support for workflow states.

Examples:

Hyrax::Workflow::ActionableObjects.new(user: current_user).each do |object|
  puts object.title
  puts object.workflow_state
end

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user:) ⇒ ActionableObjects

Returns a new instance of ActionableObjects.

Parameters:

  • user (::User)

    the user whose



26
27
28
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 26

def initialize(user:)
  @user = user
end

Instance Attribute Details

#user::User

Returns:

  • (::User)


22
23
24
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 22

def user
  @user
end

Instance Method Details

#eachHyrax::Workflow::ObjectInWorkflowDecorator



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 32

def each
  return enum_for(:each) unless block_given?
  ids_and_states = id_state_pairs
  return if ids_and_states.none?

  docs = Hyrax::SolrQueryService.new.with_ids(ids: ids_and_states.map(&:first)).solr_documents

  docs.each do |solr_doc|
    object = ObjectInWorkflowDecorator.new(solr_doc)
    _, state = ids_and_states.find { |id, _| id == object.id }

    object.workflow_state = state

    yield object
  end
end