Class: Hatchet::DefaultFilter
- Inherits:
-
Object
- Object
- Hatchet::DefaultFilter
- Defined in:
- lib/hatchet/default_filter.rb
Overview
Defines a default filter for event-triggered workflows
Instance Attribute Summary collapse
-
#expression ⇒ String
readonly
CEL expression to evaluate.
-
#payload ⇒ Hash
readonly
Static payload for the filter.
-
#scope ⇒ String?
readonly
Scope for filter matching.
Instance Method Summary collapse
-
#initialize(expression:, scope: nil, payload: {}) ⇒ DefaultFilter
constructor
A new instance of DefaultFilter.
- #to_h ⇒ Hash
-
#to_proto ⇒ V1::DefaultFilter
Convert to a V1::DefaultFilter protobuf message.
Constructor Details
#initialize(expression:, scope: nil, payload: {}) ⇒ DefaultFilter
Returns a new instance of DefaultFilter.
25 26 27 28 29 |
# File 'lib/hatchet/default_filter.rb', line 25 def initialize(expression:, scope: nil, payload: {}) @expression = expression @scope = scope @payload = payload end |
Instance Attribute Details
#expression ⇒ String (readonly)
Returns CEL expression to evaluate.
14 15 16 |
# File 'lib/hatchet/default_filter.rb', line 14 def expression @expression end |
#payload ⇒ Hash (readonly)
Returns Static payload for the filter.
20 21 22 |
# File 'lib/hatchet/default_filter.rb', line 20 def payload @payload end |
#scope ⇒ String? (readonly)
Returns Scope for filter matching.
17 18 19 |
# File 'lib/hatchet/default_filter.rb', line 17 def scope @scope end |
Instance Method Details
#to_h ⇒ Hash
32 33 34 35 36 |
# File 'lib/hatchet/default_filter.rb', line 32 def to_h h = { expression: @expression, payload: @payload } h[:scope] = @scope if @scope h end |
#to_proto ⇒ V1::DefaultFilter
Convert to a V1::DefaultFilter protobuf message
40 41 42 43 44 45 46 47 |
# File 'lib/hatchet/default_filter.rb', line 40 def to_proto payload_bytes = JSON.generate(@payload || {}).encode("UTF-8") args = { expression: @expression, payload: payload_bytes } args[:scope] = @scope if @scope ::V1::DefaultFilter.new(**args) end |