Class: Huginn::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/huginn/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/huginn/configuration.rb', line 9

def initialize
  @pagy_items = 10
  @pagy_max_items = 500
  # The unaccent function SQL emits around searchable columns/terms. Defaults
  # to the pg builtin UNACCENT(). To let GIN trigram indexes be used, point
  # this at an IMMUTABLE wrapper (see `rails g huginn:trigram_indexes`),
  # e.g. "public.f_unaccent".
  @unaccent_function = "unaccent"
  # The tsvector wrapper and dictionary used by the :full_text strategy. The
  # wrapper (see `rails g huginn:fts_indexes`) pins the dictionary and is
  # IMMUTABLE so GIN tsvector indexes are usable.
  @fts_dictionary = "portuguese"
  @fts_function = "public.f_tsvector"
  @search_strategy = :pg_trgm
  @auto_include_datatable = true
  @auto_include_searchable = true
end

Instance Attribute Details

#auto_include_datatable=(value) ⇒ Object (writeonly)

Sets the attribute auto_include_datatable

Parameters:

  • value

    the value to set the attribute auto_include_datatable to.



7
8
9
# File 'lib/huginn/configuration.rb', line 7

def auto_include_datatable=(value)
  @auto_include_datatable = value
end

#auto_include_searchable=(value) ⇒ Object (writeonly)

Sets the attribute auto_include_searchable

Parameters:

  • value

    the value to set the attribute auto_include_searchable to.



7
8
9
# File 'lib/huginn/configuration.rb', line 7

def auto_include_searchable=(value)
  @auto_include_searchable = value
end

#fts_dictionaryObject

Returns the value of attribute fts_dictionary.



5
6
7
# File 'lib/huginn/configuration.rb', line 5

def fts_dictionary
  @fts_dictionary
end

#fts_functionObject

Returns the value of attribute fts_function.



5
6
7
# File 'lib/huginn/configuration.rb', line 5

def fts_function
  @fts_function
end

#pagy_itemsObject

Returns the value of attribute pagy_items.



5
6
7
# File 'lib/huginn/configuration.rb', line 5

def pagy_items
  @pagy_items
end

#pagy_max_itemsObject

Returns the value of attribute pagy_max_items.



5
6
7
# File 'lib/huginn/configuration.rb', line 5

def pagy_max_items
  @pagy_max_items
end

#search_strategyObject

:pg_trgm -> trigram similarity (%) OR unaccent+ILIKE. The similarity cutoff is the PostgreSQL GUC pg_trgm.similarity_threshold (tune with SELECT set_limit(...)); a gin_trgm_ops GIN index on UNACCENT(col) is used when present. :full_text -> PostgreSQL full text search (lexemes): the column is matched as to_tsvector(DICTIONARY, col) vs plainto_tsquery(DICTIONARY, term). Needs the fts_function wrapper and a GIN tsvector index. :unaccent -> unaccent + ILIKE only :simple -> plain LIKE

Accepts a single symbol or an Array of symbols; when more than one is given the generated predicates are combined with OR (a row matches if any strategy matches).



42
43
44
45
46
47
48
# File 'lib/huginn/configuration.rb', line 42

def search_strategy
  if @search_strategy.is_a?(Array)
    @search_strategy.map(&:to_sym)
  else
    @search_strategy.to_sym
  end
end

#unaccent_functionObject

Returns the value of attribute unaccent_function.



5
6
7
# File 'lib/huginn/configuration.rb', line 5

def unaccent_function
  @unaccent_function
end

Instance Method Details

#auto_include_datatable?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/huginn/configuration.rb', line 50

def auto_include_datatable?
  @auto_include_datatable
end

#auto_include_searchable?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/huginn/configuration.rb', line 54

def auto_include_searchable?
  @auto_include_searchable
end