Class: Textus::Read::Audit::Query

Inherits:
Data
  • Object
show all
Defined in:
lib/textus/read/audit.rb

Overview

Value object that carries all filter parameters for an audit query. ‘matches?` checks the manifest-independent predicates so the loop body only needs to handle the zone check (which requires manifest access).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#correlation_idObject (readonly)

Returns the value of attribute correlation_id

Returns:

  • (Object)

    the current value of correlation_id



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def correlation_id
  @correlation_id
end

#keyObject (readonly)

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def key
  @key
end

#limitObject (readonly)

Returns the value of attribute limit

Returns:

  • (Object)

    the current value of limit



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def limit
  @limit
end

#roleObject (readonly)

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def role
  @role
end

#seq_sinceObject (readonly)

Returns the value of attribute seq_since

Returns:

  • (Object)

    the current value of seq_since



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def seq_since
  @seq_since
end

#sinceObject (readonly)

Returns the value of attribute since

Returns:

  • (Object)

    the current value of since



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def since
  @since
end

#verbObject (readonly)

Returns the value of attribute verb

Returns:

  • (Object)

    the current value of verb



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def verb
  @verb
end

#zoneObject (readonly)

Returns the value of attribute zone

Returns:

  • (Object)

    the current value of zone



13
14
15
# File 'lib/textus/read/audit.rb', line 13

def zone
  @zone
end

Class Method Details

.build(key: nil, zone: nil, role: nil, verb: nil, since: nil, seq_since: nil, correlation_id: nil, limit: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists



15
16
17
18
# File 'lib/textus/read/audit.rb', line 15

def self.build(key: nil, zone: nil, role: nil, verb: nil,
               since: nil, seq_since: nil, correlation_id: nil, limit: nil)
  new(key:, zone:, role:, verb:, since:, seq_since:, correlation_id:, limit:)
end

Instance Method Details

#matches?(row) ⇒ Boolean

rubocop:enable Metrics/ParameterLists

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
# File 'lib/textus/read/audit.rb', line 21

def matches?(row)
  return false if key && row["key"] != key
  return false if role && row["role"] != role
  return false if verb && row["verb"] != verb
  return false if since && (row["ts"].nil? || Time.parse(row["ts"]) < since)
  return false if seq_since && (row["seq"].nil? || row["seq"] <= seq_since)
  return false if correlation_id && row.dig("extras", "correlation_id") != correlation_id

  true
end