Class: Hyrax::CustomQueries::Navigators::CollectionMembers
- Inherits:
-
Object
- Object
- Hyrax::CustomQueries::Navigators::CollectionMembers
- Defined in:
- app/services/hyrax/custom_queries/navigators/collection_members.rb
Overview
Find members of collections and collections for members
Instance Attribute Summary collapse
- #query_service ⇒ Object readonly
Class Method Summary collapse
-
.queries ⇒ Array<Symbol>
Array<Symbol>.
Instance Method Summary collapse
-
#find_collections_for(resource:) ⇒ Array<Valkyrie::Resource>
Find child works of a given resource, and map to Valkyrie Resources.
-
#find_members_of(collection:) ⇒ Array<Valkyrie::Resource>
Find members for the given collection.
-
#initialize(query_service:) ⇒ CollectionMembers
constructor
A new instance of CollectionMembers.
Constructor Details
#initialize(query_service:) ⇒ CollectionMembers
Returns a new instance of CollectionMembers.
22 23 24 |
# File 'app/services/hyrax/custom_queries/navigators/collection_members.rb', line 22 def initialize(query_service:) @query_service = query_service end |
Instance Attribute Details
#query_service ⇒ Object (readonly)
20 21 22 |
# File 'app/services/hyrax/custom_queries/navigators/collection_members.rb', line 20 def query_service @query_service end |
Class Method Details
.queries ⇒ Array<Symbol>
Returns Array<Symbol>.
14 15 16 |
# File 'app/services/hyrax/custom_queries/navigators/collection_members.rb', line 14 def self.queries [:find_collections_for, :find_members_of] end |
Instance Method Details
#find_collections_for(resource:) ⇒ Array<Valkyrie::Resource>
Find child works of a given resource, and map to Valkyrie Resources
31 32 33 34 |
# File 'app/services/hyrax/custom_queries/navigators/collection_members.rb', line 31 def find_collections_for(resource:) query_service .find_references_by(resource: resource, property: :member_of_collection_ids) end |
#find_members_of(collection:) ⇒ Array<Valkyrie::Resource>
Find members for the given collection
41 42 43 44 |
# File 'app/services/hyrax/custom_queries/navigators/collection_members.rb', line 41 def find_members_of(collection:) query_service .find_inverse_references_by(resource: collection, property: :member_of_collection_ids) end |