Class: Segugio::Search
- Inherits:
-
Object
- Object
- Segugio::Search
- Defined in:
- lib/segugio/search.rb
Overview
Implements a feature for generic search, that allows to search using ILIKE operator, filter records by exact value and specify result order.
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #collection_name ⇒ Object
-
#initialize(relation, options = {}) ⇒ Search
constructor
A new instance of Search.
- #logger ⇒ Object
Constructor Details
#initialize(relation, options = {}) ⇒ Search
Returns a new instance of Search.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/segugio/search.rb', line 11 def initialize(relation, = {}) @relation = relation = .to_h.with_indifferent_access @configs = [:configs] || {} @options = @result = relation.all configure! generate_search_result! end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
9 10 11 |
# File 'lib/segugio/search.rb', line 9 def result @result end |
Instance Method Details
#collection_name ⇒ Object
25 26 27 |
# File 'lib/segugio/search.rb', line 25 def collection_name @collection_name ||= @relation.model_name.collection.split('/').last end |
#logger ⇒ Object
29 30 31 |
# File 'lib/segugio/search.rb', line 29 def logger @logger ||= ActiveRecord::Base.logger end |