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

Instance Method Details

#clean_array_params(params) ⇒ Array<Integer>

Normalize raw scope arguments into a flat list of unique integers.

Parameters:

  • params (Object, Array<Object>)

    raw arguments passed to the scope

Returns:

  • (Array<Integer>)

    flattened, compacted, unique integer values



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.

Parameters:

  • _auth_object (Object, nil) (defaults to: nil)

    unused authorization context (Ransack signature)

Returns:

  • (Array<Symbol>)

    ransackable scopes including +:contains_rma_item_ids+



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_checkString

SQL fragment testing whether the record has RMA items among the given returned-item IDs.

Returns:

  • (String)

    EXISTS subquery against +rma_items+ for the current table



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