Sha256: b0b1a5529902631d30fd441d2f35782da2006f388096a4e03274e826de7f6790

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  # This is the base class to be used by other search services. This helps the
  # searches to work with context attributes that are not passed from the user
  # interface.
  class ResourceSearch < Ransack::Search
    attr_reader :user, :organization, :component, :search_context

    def initialize(object, params = {}, options = {})
      @user = options[:current_user] || options[:user]
      @component = options[:component]
      @organization = options[:organization] || component&.organization
      @search_context = options[:search_context] || :participants
      configure(options)

      # The super method calls the build method in the super class, which can be
      # overridden by the individual search implementations, so call this as the
      # last thing at the initialize method. The params are passed to the
      # build method as the only argument.
      super
    end

    def configure(options)
      # This can be overridden by the search implementations in order to set
      # extra variables based on the options passed to the search class before
      # calling the build method below.
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/services/decidim/resource_search.rb
decidim-core-0.28.4 app/services/decidim/resource_search.rb
decidim-core-0.27.9 app/services/decidim/resource_search.rb
decidim-core-0.29.0 app/services/decidim/resource_search.rb
decidim-core-0.28.3 app/services/decidim/resource_search.rb
decidim-core-0.27.8 app/services/decidim/resource_search.rb
decidim-core-0.29.0.rc4 app/services/decidim/resource_search.rb
decidim-core-0.29.0.rc3 app/services/decidim/resource_search.rb
decidim-core-0.29.0.rc2 app/services/decidim/resource_search.rb
decidim-core-0.29.0.rc1 app/services/decidim/resource_search.rb
decidim-core-0.28.2 app/services/decidim/resource_search.rb
decidim-core-0.27.7 app/services/decidim/resource_search.rb
decidim-core-0.28.1 app/services/decidim/resource_search.rb
decidim-core-0.27.6 app/services/decidim/resource_search.rb
decidim-core-0.28.0 app/services/decidim/resource_search.rb
decidim-core-0.27.5 app/services/decidim/resource_search.rb
decidim-core-0.28.0.rc5 app/services/decidim/resource_search.rb
decidim-core-0.28.0.rc4 app/services/decidim/resource_search.rb
decidim-core-0.27.4 app/services/decidim/resource_search.rb
decidim-core-0.27.3 app/services/decidim/resource_search.rb