Class: Searchgasm::Config::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/searchgasm/config/search.rb

Overview

Search Configuration

Provides configuration for searchgasm

Example

Searchgasm::Config.configure do |config|
  config.search.per_page = 50
end

Class Method Summary collapse

Class Method Details

.per_pageObject

The default for per page. This is only applicaple for protected searches. Meaning you start the search with new_search or new_conditions. The reason for this not to disturb regular queries such as Whatever.find(:all). You would not expect that to be limited.

  • Default: The 2nd option in your per_page_choices, default of 25

  • Accepts: Any value in your per_page choices, nil or a blank string means “show all”



17
18
19
20
21
22
# File 'lib/searchgasm/config/search.rb', line 17

def per_page
  return @per_page if @set_per_page
  per_page = Helpers.per_page_select_choices[1]
  per_page = per_page.last if per_page.is_a?(Array)
  @per_page = per_page
end

.per_page=(value) ⇒ Object



24
25
26
27
# File 'lib/searchgasm/config/search.rb', line 24

def per_page=(value)
  @set_per_page = true
  @per_page = value
end

.remove_duplicatesObject

If you are using ActiveRecord < 2.2.0 then ActiveRecord does not remove duplicates when using the :joins option, when it should. To fix this problem searchgasm does this for you. Searchgasm tries to act just like ActiveRecord, but in this instance it doesn’t make sense.

As a result, Searchgasm removes all duplicates results in ALL search / calculation queries. It does this by forcing the DISTINCT or GROUP BY operation in your SQL. Which might come as a surprise to you since it is not the “norm”. If you don’t want searchgasm to do this, set this to false.

  • Default: true

  • Accepts: Boolean



37
38
39
40
# File 'lib/searchgasm/config/search.rb', line 37

def remove_duplicates
  return @remove_duplicates if @set_remove_duplicates
  @remove_duplicates ||= true
end

.remove_duplicates=(value) ⇒ Object

:nodoc:



46
47
48
49
# File 'lib/searchgasm/config/search.rb', line 46

def remove_duplicates=(value) # :nodoc:
  @set_remove_duplicates = true
  @remove_duplicates = value
end

.remove_duplicates?Boolean

:nodoc:

Returns:

  • (Boolean)


42
43
44
# File 'lib/searchgasm/config/search.rb', line 42

def remove_duplicates? # :nodoc:
  remove_duplicates == true
end