Module: Goddess::Query::MethodMissingMachinations
- Included in:
- CustomQueryContainer
- Defined in:
- lib/goddess/query.rb
Overview
This module provides the mechanisms for the four different query strategies:
-
#find_multiple
- #find_single
-
find an instance and if none is found, raise an exception
-
#count_multiple
- #find_single_or_nil
-
as #find_single but if no instance is found return nil
These private methods are responsible for querying the various inner services of the QueryService adapter.
Instance Method Summary collapse
- #model_class_for(model) ⇒ Object
- #setup_model(model_name) ⇒ Object
- #total_results(result_sets) ⇒ Object
Instance Method Details
#model_class_for(model) ⇒ Object
15 16 17 18 |
# File 'lib/goddess/query.rb', line 15 def model_class_for(model) internal_resource = model.respond_to?(:internal_resource) ? model.internal_resource : nil internal_resource&.safe_constantize || Wings::ModelRegistry.lookup(model) end |
#setup_model(model_name) ⇒ Object
20 21 22 23 |
# File 'lib/goddess/query.rb', line 20 def setup_model(model_name) model_name = model_class_for(model_name) model_name.respond_to?(:valkyrie_class) ? model_name.valkyrie_class : model_name end |
#total_results(result_sets) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/goddess/query.rb', line 25 def total_results(result_sets) if result_sets.present? total_result = result_sets.inject([]) do |out, set| i = out.intersection(set) out + (set - i) end total_result else result_sets end end |