Module: Consumer::Postgres::Condition

Extended by:
Condition
Included in:
Condition
Defined in:
lib/consumer/postgres/postgres.rb

Instance Method Summary collapse

Instance Method Details

#compose(condition: nil, correlation: nil) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/consumer/postgres/postgres.rb', line 63

def compose(condition: nil, correlation: nil)
  composed_condition = []

  unless condition.nil?
    composed_condition << condition
  end

  unless correlation.nil?
    Correlation.assure(correlation)

    composed_condition << "metadata->>'correlationStreamName' like '#{correlation}-%'"
  end

  return nil if composed_condition.empty?

  sql_condition = composed_condition.join(' AND ')

  sql_condition
end