Module: Sequel::Plugins::TextSearchable

Defined in:
lib/sequel/plugins/text_searchable.rb

Defined Under Namespace

Modules: ClassMethods, DatasetMethods, InstanceMethods

Constant Summary collapse

DEFAULT_OPTIONS =
{
  column: :text_search,
  search_options: {
    to_tsquery: :websearch,
    language: "english",
    rank: true,
  },
  terms: nil,
}.freeze

Class Method Summary collapse

Class Method Details

.apply(model) ⇒ Object



16
17
18
19
20
# File 'lib/sequel/plugins/text_searchable.rb', line 16

def self.apply(model, *)
  raise "The :dirty plugin must be loaded first. Use `plugin :dirty`." if
    !model.plugins.include?(Sequel::Plugins::Dirty) ||
      model.plugins.index(Sequel::Plugins::Dirty) > model.plugins.index(self)
end

.configure(model, opts = DEFAULT_OPTIONS) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/sequel/plugins/text_searchable.rb', line 22

def self.configure(model, opts=DEFAULT_OPTIONS)
  opts = DEFAULT_OPTIONS.merge(opts)
  model.text_search_column = opts[:column]
  model.text_search_options = opts[:search_options]
  model.text_search_terms = opts[:terms]
  SequelTextSearchable.searchable_models << model
end