Class: Decidim::ResourceSearch
- Inherits:
-
Ransack::Search
- Object
- Ransack::Search
- Decidim::ResourceSearch
- Defined in:
- app/services/decidim/resource_search.rb
Overview
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.
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
-
#search_context ⇒ Object
readonly
Returns the value of attribute search_context.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #configure(options) ⇒ Object
-
#initialize(object, params = {}, options = {}) ⇒ ResourceSearch
constructor
A new instance of ResourceSearch.
Constructor Details
#initialize(object, params = {}, options = {}) ⇒ ResourceSearch
Returns a new instance of ResourceSearch.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/decidim/resource_search.rb', line 10 def initialize(object, params = {}, = {}) @user = [:current_user] || [:user] @component = [:component] @organization = [:organization] || component&.organization @search_context = [:search_context] || :participants configure() # 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 |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
8 9 10 |
# File 'app/services/decidim/resource_search.rb', line 8 def component @component end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
8 9 10 |
# File 'app/services/decidim/resource_search.rb', line 8 def organization @organization end |
#search_context ⇒ Object (readonly)
Returns the value of attribute search_context.
8 9 10 |
# File 'app/services/decidim/resource_search.rb', line 8 def search_context @search_context end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'app/services/decidim/resource_search.rb', line 8 def user @user end |
Instance Method Details
#configure(options) ⇒ Object
24 25 26 27 28 |
# File 'app/services/decidim/resource_search.rb', line 24 def configure() # 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 |