Class: Api::Filters::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/api/filters/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(condition = nil) ⇒ Query



5
6
7
# File 'lib/api/filters/query.rb', line 5

def initialize(condition = nil)
  @condition = condition
end

Instance Method Details

#build_paramObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/api/filters/query.rb', line 9

def build_param
  q = %(%#{@condition}%)
  q.downcase!
  [ "LOWER(buyer_name) LIKE ? " \
    "OR LOWER(buyer_email) LIKE ? " \
    "OR LOWER(reason) LIKE ? " \
    "OR LOWER(owner_id) LIKE ? " \
    "OR payment_used_id LIKE ? " \
    "OR LOWER(order_external_id) LIKE ? " \
    "OR LOWER(payment_external_id) LIKE ? " \
    "OR buyer_cep LIKE ?",
    q, q, q, q, q, q, q, q ] unless @condition.nil?
end