Class: PgSearch::ScopeOptions
- Inherits:
-
Object
- Object
- PgSearch::ScopeOptions
- Defined in:
- lib/pg_search/scope_options.rb
Defined Under Namespace
Modules: PgSearchRankTableAliasing, WithPgSearchHighlight, WithPgSearchRank
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#feature_options ⇒ Object
readonly
Returns the value of attribute feature_options.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #apply(scope) ⇒ Object
-
#initialize(config) ⇒ ScopeOptions
constructor
A new instance of ScopeOptions.
Constructor Details
#initialize(config) ⇒ ScopeOptions
Returns a new instance of ScopeOptions.
9 10 11 12 13 |
# File 'lib/pg_search/scope_options.rb', line 9 def initialize(config) @config = config @model = config.model = config. end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/pg_search/scope_options.rb', line 7 def config @config end |
#feature_options ⇒ Object (readonly)
Returns the value of attribute feature_options.
7 8 9 |
# File 'lib/pg_search/scope_options.rb', line 7 def end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/pg_search/scope_options.rb', line 7 def model @model end |
Instance Method Details
#apply(scope) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pg_search/scope_options.rb', line 15 def apply(scope) scope = include_table_aliasing_for_rank(scope) rank_table_alias = scope.pg_search_rank_table_alias(include_counter: true) scope .joins(rank_join(rank_table_alias)) .order(Arel.sql("#{rank_table_alias}.rank DESC, #{order_within_rank}")) .extend(WithPgSearchRank) .extend(WithPgSearchHighlight[feature_for(:tsearch)]) end |