Class: Hyrax::Workflow::ActionableObjects
- Inherits:
-
Object
- Object
- Hyrax::Workflow::ActionableObjects
- 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.
Instance Attribute Summary collapse
-
#page ⇒ Object
Returns the value of attribute page.
- #page of results to return, 1 based(ofresultsto) ⇒ Integer
-
#per_page ⇒ Object
Returns the value of attribute per_page.
- #per_page number of results in the page(numberofresults) ⇒ Integer
- #user ⇒ ::User
- #workflow_state_filter ⇒ String
Instance Method Summary collapse
- #each ⇒ Hyrax::Workflow::ObjectInWorkflowDecorator
-
#initialize(user:, workflow_state_filter: nil) ⇒ ActionableObjects
constructor
A new instance of ActionableObjects.
-
#total_count ⇒ Integer
Total number of entities selected.
Constructor Details
#initialize(user:, workflow_state_filter: nil) ⇒ ActionableObjects
Returns a new instance of ActionableObjects.
39 40 41 42 43 44 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 39 def initialize(user:, workflow_state_filter: nil) @user = user @workflow_state_filter = workflow_state_filter @page = 1 @per_page = 10 end |
Instance Attribute Details
#page ⇒ Object
Returns the value of attribute page.
30 31 32 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 30 def page @page end |
#page of results to return, 1 based(ofresultsto) ⇒ Integer
30 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 30 attr_accessor :page |
#per_page ⇒ Object
Returns the value of attribute per_page.
34 35 36 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 34 def per_page @per_page end |
#per_page number of results in the page(numberofresults) ⇒ Integer
34 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 34 attr_accessor :per_page |
#user ⇒ ::User
22 23 24 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 22 def user @user end |
#workflow_state_filter ⇒ String
26 27 28 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 26 def workflow_state_filter @workflow_state_filter end |
Instance Method Details
#each ⇒ Hyrax::Workflow::ObjectInWorkflowDecorator
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 48 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(page: @page, rows: @per_page, sort: 'system_create_dtsi ASC') 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 |
#total_count ⇒ Integer
Returns total number of entities selected.
68 69 70 71 |
# File 'app/services/hyrax/workflow/actionable_objects.rb', line 68 def total_count PermissionQuery.scope_entities_for_the_user(user: user, workflow_state_filter: workflow_state_filter) .count end |