Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 8 additions & 26 deletions lib/pg_search/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def alias(*strings)
end
end

def columns
regular_columns + associated_columns
end
def columns = regular_columns + associated_columns

def regular_columns
return [] unless options[:against]
Expand All @@ -43,37 +41,21 @@ def associations
end.flatten
end

def associated_columns
associations.map(&:columns).flatten
end
def associated_columns = associations.map(&:columns).flatten

def query
options[:query].to_s
end
def query = options[:query].to_s

def ignore
Array(options[:ignoring])
end
def ignore = Array(options[:ignoring])

def ranking_sql
options[:ranked_by]
end
def ranking_sql = options[:ranked_by]

def features
Array(options[:using])
end
def features = Array(options[:using])

def feature_options
@feature_options ||= {}.tap do |hash|
features.map do |feature_name, feature_options|
hash[feature_name] = feature_options
end
end
@feature_options ||= features.to_h { |name, opts| [name, opts] }
end

def order_within_rank
options[:order_within_rank]
end
def order_within_rank = options[:order_within_rank]

private

Expand Down
39 changes: 16 additions & 23 deletions lib/pg_search/features/tsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ def headline_options

%w[
StartSel StopSel MaxFragments MaxWords MinWords ShortWord FragmentDelimiter HighlightAll
].reduce({}) do |hash, key|
hash.tap do
value = indifferent_options[:highlight][key]

hash[key] = ts_headline_option_value(value)
end
].to_h do |key|
[key, ts_headline_option_value(indifferent_options[:highlight][key])]
end
end

Expand All @@ -63,23 +59,20 @@ def deprecated_headline_options

%w[
start_sel stop_sel max_fragments max_words min_words short_word fragment_delimiter highlight_all
].reduce({}) do |hash, deprecated_key|
hash.tap do
value = indifferent_options[:highlight][deprecated_key]

unless value.nil?
key = deprecated_key.camelize

warn(
"pg_search 3.0 will no longer accept :#{deprecated_key} as an argument to :ts_headline, " \
"use :#{key} instead.",
category: :deprecated,
uplevel: 1
)

hash[key] = ts_headline_option_value(value)
end
end
].each_with_object({}) do |deprecated_key, hash|
value = indifferent_options[:highlight][deprecated_key]
next if value.nil?

key = deprecated_key.camelize

warn(
"pg_search 3.0 will no longer accept :#{deprecated_key} as an argument to :ts_headline, " \
"use :#{key} instead.",
category: :deprecated,
uplevel: 1
)

hash[key] = ts_headline_option_value(value)
end
end

Expand Down
Loading