Class: Hatchet::UserEventCondition

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/conditions.rb

Overview

A condition that waits for a user event with a specific key

Examples:

Wait for a user:update event

Hatchet::UserEventCondition.new(event_key: "user:update")

With filter expression

Hatchet::UserEventCondition.new(event_key: "user:update", expression: "input.user_id == '1234'")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_key:, expression: nil) ⇒ UserEventCondition

Returns a new instance of UserEventCondition.

Parameters:

  • event_key (String)

    The event key to wait for

  • expression (String, nil) (defaults to: nil)

    Optional CEL filter expression



39
40
41
42
# File 'lib/hatchet/conditions.rb', line 39

def initialize(event_key:, expression: nil)
  @event_key = event_key
  @expression = expression
end

Instance Attribute Details

#event_keyString (readonly)

Returns The event key to listen for.

Returns:

  • (String)

    The event key to listen for



32
33
34
# File 'lib/hatchet/conditions.rb', line 32

def event_key
  @event_key
end

#expressionString? (readonly)

Returns Optional CEL expression to filter events.

Returns:

  • (String, nil)

    Optional CEL expression to filter events



35
36
37
# File 'lib/hatchet/conditions.rb', line 35

def expression
  @expression
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


45
46
47
48
49
# File 'lib/hatchet/conditions.rb', line 45

def to_h
  h = { type: "user_event", event_key: @event_key }
  h[:expression] = @expression if @expression
  h
end