Class: Hyrax::CustomQueries::FindAccessControl
- Inherits:
-
Object
- Object
- Hyrax::CustomQueries::FindAccessControl
- Defined in:
- app/services/hyrax/custom_queries/find_access_control.rb
Overview
Instance Attribute Summary collapse
-
#query_service ⇒ Object
readonly
Returns the value of attribute query_service.
Class Method Summary collapse
Instance Method Summary collapse
- #find_access_control_for(resource:) ⇒ Object
-
#initialize(query_service:) ⇒ FindAccessControl
constructor
A new instance of FindAccessControl.
Constructor Details
#initialize(query_service:) ⇒ FindAccessControl
Returns a new instance of FindAccessControl.
11 12 13 |
# File 'app/services/hyrax/custom_queries/find_access_control.rb', line 11 def initialize(query_service:) @query_service = query_service end |
Instance Attribute Details
#query_service ⇒ Object (readonly)
Returns the value of attribute query_service.
15 16 17 |
# File 'app/services/hyrax/custom_queries/find_access_control.rb', line 15 def query_service @query_service end |
Class Method Details
.queries ⇒ Object
7 8 9 |
# File 'app/services/hyrax/custom_queries/find_access_control.rb', line 7 def self.queries [:find_access_control_for] end |
Instance Method Details
#find_access_control_for(resource:) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/services/hyrax/custom_queries/find_access_control.rb', line 18 def find_access_control_for(resource:) query_service .find_inverse_references_by(resource: resource, property: :access_to) .find { |r| r.is_a?(Hyrax::AccessControl) } || raise(Valkyrie::Persistence::ObjectNotFoundError) rescue ArgumentError # some adapters raise ArgumentError for missing resources raise(Valkyrie::Persistence::ObjectNotFoundError) end |