| Class | SearchApi::Bridge::Base |
| In: |
lib/search_api/bridge.rb
|
| Parent: | Object |
Base class for SearchApi bridges.
Such a bridge have following responsabilities:
This is done by the automatic_search_attribute_builders method.
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.
This is done by the merge_find_options method.
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.
# File lib/search_api/bridge.rb, line 47
47: def automatic_search_attribute_builders(options)
48: []
49: end
This methods returns a merge of options in options_array.
Default SearchApi::Bridge::Base behavior is to raise NotImplementedError.
# File lib/search_api/bridge.rb, line 70
70: def merge_find_options(options_array)
71: raise NotImplementedError.new
72: end
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.
# File lib/search_api/bridge.rb, line 63
63: def rewrite_search_attribute_builder(search_attribute_builder)
64: end