Class: BMC::Filter::ByKeyValues

Inherits:
ByKeyValue show all
Defined in:
app/filters/bmc/filter/by_key_values.rb

Instance Attribute Summary

Attributes inherited from ByKeyValue

#key

Instance Method Summary collapse

Methods inherited from ByKeyValue

#column_for, #initialize

Constructor Details

This class inherits a constructor from BMC::Filter::ByKeyValue

Instance Method Details

#call(query, value) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/filters/bmc/filter/by_key_values.rb', line 2

def call(query, value)
  value = value.split if value.is_a?(String)
  value = value.select(&:present?)

  return query if value == ["all"]

  column = column_for(query)

  if value.any?
    query.where("#{column} IN (?)", value)
  else
    query
  end
end