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.
7 8 9 10 11 |
# File 'lib/pg_search/scope_options.rb', line 7 def initialize(config) @config = config @model = config.model = config. end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/pg_search/scope_options.rb', line 5 def config @config end |
#feature_options ⇒ Object (readonly)
Returns the value of attribute feature_options.
5 6 7 |
# File 'lib/pg_search/scope_options.rb', line 5 def end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/pg_search/scope_options.rb', line 5 def model @model end |
Instance Method Details
#apply(scope) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pg_search/scope_options.rb', line 13 def apply(scope) scope = include_table_aliasing_for_rank(scope) rank_table_alias = scope.pg_search_rank_table_alias(include_counter: true) rank_subquery = subquery.arel.as(rank_table_alias) scope .joins(rank_join(rank_subquery)) .order(rank_subquery[:rank].desc) .order(order_within_rank) .extend(WithPgSearchRank) .extend(WithPgSearchHighlight[feature_for(:tsearch)]) end |