Module: Segugio
- Defined in:
- lib/segugio.rb,
lib/segugio/search.rb,
lib/segugio/version.rb,
lib/segugio/searchable.rb
Defined Under Namespace
Modules: Searchable Classes: Error, Search
Constant Summary collapse
- VERSION =
'0.1.2'
Class Attribute Summary collapse
-
.__search_method_name ⇒ Object
Define an accessor where to store current search method name.
Class Method Summary collapse
-
.search_method_name ⇒ Object
Returns current search method name of Segugio.
-
.search_method_name=(name) ⇒ Object
Updates current search method name of Segugio.
Class Attribute Details
.__search_method_name ⇒ Object
Define an accessor where to store current search method name.
8 9 10 |
# File 'lib/segugio/searchable.rb', line 8 def __search_method_name @__search_method_name end |
Class Method Details
.search_method_name ⇒ Object
Returns current search method name of Segugio.
11 12 13 |
# File 'lib/segugio/searchable.rb', line 11 def search_method_name __sarch_method_name end |
.search_method_name=(name) ⇒ Object
Updates current search method name of Segugio. This method will remove the old search method and define a new one with the given name. e.g.: ‘Segugio.search_method_name = :my_search` will define a new `my_search` method on all models that extend `Segugio::Searchable`.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/segugio/searchable.rb', line 19 def search_method_name=(name) return if name.to_s.strip == '' || name.to_s.strip == __search_method_name current_method_name = __search_method_name || 'search' Segugio::Searchable.remove_method(current_method_name) if Segugio::Searchable.method_defined?(current_method_name) self.__search_method_name = name Segugio::Searchable.define_method(name) do |query: '', filters: {}, exclude: {}, order: [], configs: {}| segugio_perform_search(query: query, filters: filters, exclude: exclude, order: order, configs: configs) end end |