Class: PgSearch::ScopeOptions
- Inherits:
-
Object
- Object
- PgSearch::ScopeOptions
- Defined in:
- lib/pg_search/scope_options.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(name, model, config) ⇒ ScopeOptions
constructor
A new instance of ScopeOptions.
- #to_relation ⇒ Object
Constructor Details
#initialize(name, model, config) ⇒ ScopeOptions
Returns a new instance of ScopeOptions.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pg_search/scope_options.rb', line 9 def initialize(name, model, config) @name = name @model = model @config = config @feature_options = @config.features.inject({}) do |features_hash, (feature_name, )| features_hash.merge( feature_name => ) end @feature_names = @config.features.map { |feature_name, | feature_name } end |
Instance Attribute Details
#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
#to_relation ⇒ Object
22 23 24 |
# File 'lib/pg_search/scope_options.rb', line 22 def to_relation @model.select("#{quoted_table_name}.*, (#{rank}) AS pg_search_rank").where(conditions).order("pg_search_rank DESC, #{order_within_rank}").joins(joins) end |