Class: Spree::Posts::Find
- Inherits:
-
BaseFinder
- Object
- BaseFinder
- Spree::Posts::Find
- Defined in:
- app/finders/spree/posts/find.rb
Instance Attribute Summary
Attributes inherited from BaseFinder
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(scope:, params:) ⇒ Find
constructor
A new instance of Find.
Constructor Details
#initialize(scope:, params:) ⇒ Find
Returns a new instance of Find.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/finders/spree/posts/find.rb', line 4 def initialize(scope:, params:) super(scope: scope, params: params) @scope = scope @query = params[:q].presence&.strip @ids = String(params.dig(:filter, :ids)).split(',') @slugs = String(params.dig(:filter, :slugs)).split(',') @category_ids = String(params.dig(:filter, :category_ids)).split(',') = String(params.dig(:filter, :author_ids)).split(',') = params.dig(:filter, :tags).to_s.split(',').compact_blank @sort_by = params[:sort_by] @published = params.dig(:filter, :published) end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/finders/spree/posts/find.rb', line 17 def execute posts = by_ids(scope) posts = by_slugs(posts) posts = by_query(posts) posts = by_category_ids(posts) posts = (posts) posts = (posts) posts = by_published(posts) posts = ordered(posts) posts.distinct end |