Class: Hyrax::CustomQueries::Navigators::ParentCollectionsNavigator
- Inherits:
-
Object
- Object
- Hyrax::CustomQueries::Navigators::ParentCollectionsNavigator
- Defined in:
- app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb
Overview
Navigate from a resource to the parent collections of the resource.
Instance Attribute Summary collapse
- #query_service ⇒ Object readonly
Class Method Summary collapse
-
.queries ⇒ Object
Define the queries that can be fulfilled by this navigator.
Instance Method Summary collapse
-
#find_parent_collection_ids(resource:) ⇒ Array<Valkyrie::ID>
Find the ids of parent collections of a given resource, and map to Valkyrie Resources IDs.
-
#find_parent_collections(resource:) ⇒ Array<Valkyrie::Resource>
Find parent collections of a given resource, and map to Valkyrie Resources.
-
#initialize(query_service:) ⇒ ParentCollectionsNavigator
constructor
A new instance of ParentCollectionsNavigator.
Constructor Details
#initialize(query_service:) ⇒ ParentCollectionsNavigator
Returns a new instance of ParentCollectionsNavigator.
19 20 21 |
# File 'app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb', line 19 def initialize(query_service:) @query_service = query_service end |
Instance Attribute Details
#query_service ⇒ Object (readonly)
17 18 19 |
# File 'app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb', line 17 def query_service @query_service end |
Class Method Details
.queries ⇒ Object
Define the queries that can be fulfilled by this navigator.
13 14 15 |
# File 'app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb', line 13 def self.queries [:find_parent_collections, :find_parent_collection_ids] end |
Instance Method Details
#find_parent_collection_ids(resource:) ⇒ Array<Valkyrie::ID>
Find the ids of parent collections of a given resource, and map to Valkyrie Resources IDs
40 41 42 |
# File 'app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb', line 40 def find_parent_collection_ids(resource:) resource.member_of_collection_ids end |
#find_parent_collections(resource:) ⇒ Array<Valkyrie::Resource>
Find parent collections of a given resource, and map to Valkyrie Resources
29 30 31 32 |
# File 'app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb', line 29 def find_parent_collections(resource:) query_service .find_many_by_ids(ids: find_parent_collection_ids(resource: resource)) end |