Class: Oversee::Search
- Inherits:
-
Object
- Object
- Oversee::Search
- Defined in:
- app/service/oversee/search.rb
Constant Summary collapse
- DEFAULT_SEARCHABLE_ATTRIBUTES =
%w[name title email email_address]
Instance Method Summary collapse
- #call ⇒ Object
- #default_searchable_attribute ⇒ Object
-
#initialize(collection:, resource_class:, query: nil) ⇒ Search
constructor
A new instance of Search.
Constructor Details
#initialize(collection:, resource_class:, query: nil) ⇒ Search
Returns a new instance of Search.
4 5 6 7 8 |
# File 'app/service/oversee/search.rb', line 4 def initialize(collection:, resource_class:, query: nil) @collection = collection @resource_class = resource_class @query = query end |
Instance Method Details
#call ⇒ Object
10 11 12 13 |
# File 'app/service/oversee/search.rb', line 10 def call return @collection if @query.blank? || @resource_class.blank? default_searchable_by end |
#default_searchable_attribute ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/service/oversee/search.rb', line 15 def default_searchable_attribute DEFAULT_SEARCHABLE_ATTRIBUTES.each do |attr| return attr if @resource_class.column_names.include?(attr) end return @resource_class.primary_key end |