Class: Hyrax::CustomQueries::Navigators::ChildWorksNavigator

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/custom_queries/navigators/child_works_navigator.rb

Overview

Navigate from a resource to the child works in the resource.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_service:) ⇒ ChildWorksNavigator

Returns a new instance of ChildWorksNavigator.

Since:

  • 3.0.0


19
20
21
# File 'app/services/hyrax/custom_queries/navigators/child_works_navigator.rb', line 19

def initialize(query_service:)
  @query_service = query_service
end

Instance Attribute Details

#query_serviceObject (readonly)

Since:

  • 3.0.0


17
18
19
# File 'app/services/hyrax/custom_queries/navigators/child_works_navigator.rb', line 17

def query_service
  @query_service
end

Class Method Details

.queriesObject

Define the queries that can be fulfilled by this navigator.

Since:

  • 3.0.0


13
14
15
# File 'app/services/hyrax/custom_queries/navigators/child_works_navigator.rb', line 13

def self.queries
  [:find_child_works, :find_child_work_ids]
end

Instance Method Details

#find_child_work_ids(resource:) ⇒ Array<Valkyrie::ID>

Find the ids of child works of a given resource, and map to Valkyrie Resources IDs

Parameters:

  • resource (Valkyrie::Resource)

Returns:

  • (Array<Valkyrie::ID>)

Since:

  • 3.0.0


39
40
41
# File 'app/services/hyrax/custom_queries/navigators/child_works_navigator.rb', line 39

def find_child_work_ids(resource:)
  find_child_works(resource: resource).map(&:id)
end

#find_child_works(resource:) ⇒ Array<Valkyrie::Resource>

Find child works of a given resource, and map to Valkyrie Resources

Parameters:

  • resource (Valkyrie::Resource)

Returns:

  • (Array<Valkyrie::Resource>)

Since:

  • 3.0.0


29
30
31
# File 'app/services/hyrax/custom_queries/navigators/child_works_navigator.rb', line 29

def find_child_works(resource:)
  query_service.find_members(resource: resource).select(&:work?)
end