Class: Autoselect::Hook
- Inherits:
-
Object
- Object
- Autoselect::Hook
- Defined in:
- lib/autoselect/hook.rb
Overview
lib/autoselect/hook.rb
Base class for multi-step levels that chain autoselects across models. The canonical example is OTU's catalogue_of_life level, which hooks into TaxonName's catalogue_of_life level to create a TaxonName first, then uses the resulting taxon_name_id to create the OTU.
Hook execution is internal (Ruby, not HTTP). The hook calls the sub-autoselect level directly, collects the yielded attributes, and passes them back to the parent level's record creation logic.
Instance Method Summary collapse
-
#call(term:, project_id: nil, user_id: nil, **kwargs) ⇒ Array<Hash>
Execute the hook.
-
#hooked_autoselect_class ⇒ Class
The autoselect class to delegate to for the sub-request.
-
#hooked_level ⇒ Symbol
The level key on the hooked autoselect to invoke.
-
#yields ⇒ Symbol
The attribute this hook yields, e.g.
Instance Method Details
#call(term:, project_id: nil, user_id: nil, **kwargs) ⇒ Array<Hash>
Execute the hook.
35 36 37 |
# File 'lib/autoselect/hook.rb', line 35 def call(term:, project_id: nil, user_id: nil, **kwargs) raise NotImplementedError, "#{self.class} must implement #call" end |
#hooked_autoselect_class ⇒ Class
Returns the autoselect class to delegate to for the sub-request.
20 21 22 |
# File 'lib/autoselect/hook.rb', line 20 def hooked_autoselect_class raise NotImplementedError, "#{self.class} must implement #hooked_autoselect_class" end |
#hooked_level ⇒ Symbol
Returns the level key on the hooked autoselect to invoke.
25 26 27 |
# File 'lib/autoselect/hook.rb', line 25 def hooked_level raise NotImplementedError, "#{self.class} must implement #hooked_level" end |
#yields ⇒ Symbol
Returns the attribute this hook yields, e.g. :taxon_name_id.
15 16 17 |
# File 'lib/autoselect/hook.rb', line 15 def yields raise NotImplementedError, "#{self.class} must implement #yields" end |