Class: SearchApi::Bridge::Base
- Inherits:
-
Object
- Object
- SearchApi::Bridge::Base
- Defined in:
- lib/search_api/bridge.rb
Overview
Base class for SearchApi bridges.
Such a bridge have following responsabilities:
-
predefining search attributes, when the model of a SearchApi::Search::Base subclass is set.
This is done by the automatic_search_attribute_builders method.
-
rewriting SearchAttributeBuilder instances.
The SearchApi::Search::Base class defines a generic, dull, way to define search attributes.
Precisely speaking, the SearchApi::Search::Base.add_search_attribute method, the one that actually defines search attributes, has strong requirements on its SearchAttributeBuilder parameter.
A bridge is able to define a domain-specific way to define search attributes. This is the bridge’s reponsability to translate these domain-specific SearchAttributeBuilder instances into strict SearchAttributeBuilder instances, that SearchApi::Search::Base.add_search_attribute can use.
This is done by the rewrite_search_attribute_builder method.
-
merging find options, in order to build a single option from those built by several search attributes.
This is done by the merge_find_options method.
Direct Known Subclasses
Instance Method Summary collapse
-
#automatic_search_attribute_builders(options) ⇒ Object
This method is called when a SearchApi::Search::Base’s model is set, in order to predefine some relevant search keys.
-
#merge_find_options(options_array) ⇒ Object
This methods returns a merge of options in options_array.
-
#rewrite_search_attribute_builder(search_attribute_builder) ⇒ Object
This method is called when a SearchApi::Search::Base.search_accessor is called, to allow SearchApi::Bridge::Base subclasses to handle special builder options.
Instance Method Details
#automatic_search_attribute_builders(options) ⇒ Object
This method is called when a SearchApi::Search::Base’s model is set, in order to predefine some relevant search keys.
Returns an Array of SearchAttributeBuilder instances.
Each builder can be used as an argument for SearchApi::Search::Base.search_accessor.
Default SearchApi::Bridge::Base behavior is to return an empty Array: there is no automatic search attributes by default.
47 48 49 |
# File 'lib/search_api/bridge.rb', line 47 def automatic_search_attribute_builders() [] end |
#merge_find_options(options_array) ⇒ Object
This methods returns a merge of options in options_array.
Default SearchApi::Bridge::Base behavior is to raise NotImplementedError.
70 71 72 |
# File 'lib/search_api/bridge.rb', line 70 def () raise NotImplementedError.new end |
#rewrite_search_attribute_builder(search_attribute_builder) ⇒ Object
This method is called when a SearchApi::Search::Base.search_accessor is called, to allow SearchApi::Bridge::Base subclasses to handle special builder options.
Rewrites a SearchAttributeBuilder.
On output, search_attribute_builder should be a valid SearchApi::Search::Base.add_search_attribute argument.
Default SearchApi::Bridge::Base behavior is to leave the builder untouched.
Subclasses may take the chance to use some specific options.
63 64 |
# File 'lib/search_api/bridge.rb', line 63 def rewrite_search_attribute_builder(search_attribute_builder) end |