Module: Models::SearchableViewWithRmaItems::ClassMethods
- Defined in:
- app/concerns/models/searchable_view_with_rma_items.rb
Overview
ActiveSupport::Concern mixin: class methods.
Instance Method Summary collapse
-
#clean_array_params(params) ⇒ Array<Integer>
Normalize raw scope arguments into a flat list of unique integers.
-
#ransackable_scopes(_auth_object = nil) ⇒ Array<Symbol>
Expose contains_rma_item_ids to Ransack so it is accepted in both lenient and strict (ignore_unknown_conditions: false) probe mode.
-
#rma_item_sql_check ⇒ String
SQL fragment testing whether the record has RMA items among the given returned-item IDs.
Instance Method Details
#clean_array_params(params) ⇒ Array<Integer>
Normalize raw scope arguments into a flat list of unique integers.
21 22 23 |
# File 'app/concerns/models/searchable_view_with_rma_items.rb', line 21 def clean_array_params(params) [params].flatten.compact.uniq.map(&:to_i) end |
#ransackable_scopes(_auth_object = nil) ⇒ Array<Symbol>
Expose contains_rma_item_ids to Ransack so it is accepted in both lenient
and strict (ignore_unknown_conditions: false) probe mode.
14 15 16 |
# File 'app/concerns/models/searchable_view_with_rma_items.rb', line 14 def ransackable_scopes(_auth_object = nil) super + %i[contains_rma_item_ids] end |
#rma_item_sql_check ⇒ String
SQL fragment testing whether the record has RMA items among the given returned-item IDs.
27 28 29 30 31 32 33 34 35 |
# File 'app/concerns/models/searchable_view_with_rma_items.rb', line 27 def rma_item_sql_check %{ EXISTS (select 1 from rma_items ri where ri.rma_id = #{table_name}.id and ri.returned_item_id IN (?)) } end |