Class: Huginn::Configuration
- Inherits:
-
Object
- Object
- Huginn::Configuration
- Defined in:
- lib/huginn/configuration.rb
Instance Attribute Summary collapse
-
#auto_include_datatable ⇒ Object
writeonly
Sets the attribute auto_include_datatable.
-
#auto_include_searchable ⇒ Object
writeonly
Sets the attribute auto_include_searchable.
-
#fts_dictionary ⇒ Object
Returns the value of attribute fts_dictionary.
-
#fts_function ⇒ Object
Returns the value of attribute fts_function.
-
#pagy_items ⇒ Object
Returns the value of attribute pagy_items.
-
#pagy_max_items ⇒ Object
Returns the value of attribute pagy_max_items.
-
#search_strategy ⇒ Object
:pg_trgm -> trigram similarity (%) OR unaccent+ILIKE.
-
#unaccent_function ⇒ Object
Returns the value of attribute unaccent_function.
Instance Method Summary collapse
- #auto_include_datatable? ⇒ Boolean
- #auto_include_searchable? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
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
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
7 8 9 |
# File 'lib/huginn/configuration.rb', line 7 def auto_include_searchable=(value) @auto_include_searchable = value end |
#fts_dictionary ⇒ Object
Returns the value of attribute fts_dictionary.
5 6 7 |
# File 'lib/huginn/configuration.rb', line 5 def fts_dictionary @fts_dictionary end |
#fts_function ⇒ Object
Returns the value of attribute fts_function.
5 6 7 |
# File 'lib/huginn/configuration.rb', line 5 def fts_function @fts_function end |
#pagy_items ⇒ Object
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_items ⇒ Object
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_strategy ⇒ Object
: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_function ⇒ Object
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
50 51 52 |
# File 'lib/huginn/configuration.rb', line 50 def auto_include_datatable? @auto_include_datatable end |
#auto_include_searchable? ⇒ Boolean
54 55 56 |
# File 'lib/huginn/configuration.rb', line 54 def auto_include_searchable? @auto_include_searchable end |