Class: Releaf::Search

Inherits:
Object
  • Object
show all
Defined in:
app/lib/releaf/search.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation:, fields:, text:) ⇒ Search

Returns a new instance of Search.


13
14
15
16
17
# File 'app/lib/releaf/search.rb', line 13

def initialize(relation: , fields:, text:)
  self.relation = relation.all
  self.fields = fields
  self.text = text
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields


3
4
5
# File 'app/lib/releaf/search.rb', line 3

def fields
  @fields
end

#join_indexObject

Returns the value of attribute join_index


3
4
5
# File 'app/lib/releaf/search.rb', line 3

def join_index
  @join_index
end

#relationObject

Returns the value of attribute relation


3
4
5
# File 'app/lib/releaf/search.rb', line 3

def relation
  @relation
end

#searchable_arel_fieldsObject

Returns the value of attribute searchable_arel_fields


3
4
5
# File 'app/lib/releaf/search.rb', line 3

def searchable_arel_fields
  @searchable_arel_fields
end

#textObject

Returns the value of attribute text


3
4
5
# File 'app/lib/releaf/search.rb', line 3

def text
  @text
end

Class Method Details

.prepare(relation:, fields:, text:) ⇒ Object


7
8
9
10
11
# File 'app/lib/releaf/search.rb', line 7

def self.prepare(relation:, fields:, text:)
  searcher = new(relation: relation, fields: fields, text: text)
  searcher.prepare
  searcher.relation
end

Instance Method Details

#prepareObject


19
20
21
22
23
24
25
# File 'app/lib/releaf/search.rb', line 19

def prepare
  self.join_index = 0
  self.searchable_arel_fields = []

  join_search_tables(base_class)
  add_search_to_relation
end