Class: Inquirex::Actions::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/inquirex/actions/base.rb

Overview

Abstract base for action effects — the executable units inside an action block. Subclasses implement #call and, when serializable, #to_h / .from_h following the same round-trip pattern as Rules::Base.

Effects that wrap Ruby procs (Actions::Custom) return false from #serializable? and are stripped from JSON, consistent with how lambdas are handled everywhere else in Inquirex.

Direct Known Subclasses

Custom, SendEmail, Webhook

Instance Method Summary collapse

Instance Method Details

#call(answers, outbox) ⇒ void

This method returns an undefined value.

Executes the effect. Email-building effects append Mail::Message objects to the outbox; custom effects may do anything server-side.

Parameters:

  • answers (Answers)

    completed answers

  • outbox (Outbox)

    collector for built messages

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/inquirex/actions/base.rb', line 19

def call(answers, outbox)
  raise NotImplementedError, "#{self.class}#call must be implemented"
end

#serializable?Boolean

Returns whether this effect survives JSON serialization.

Returns:

  • (Boolean)

    whether this effect survives JSON serialization



24
# File 'lib/inquirex/actions/base.rb', line 24

def serializable? = true

#to_hHash

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/inquirex/actions/base.rb', line 36

def to_h
  raise NotImplementedError, "#{self.class}#to_h must be implemented"
end

#validate_against(_definition) ⇒ Object

Hook for effects that must be checked against the definition carrying them (e.g. Webhook vs allowed_domains). Runs inside Definition#validate!, which both DSL-built and JSON-rehydrated definitions pass through — so violations fail at load time.

Parameters:

Raises:



33
# File 'lib/inquirex/actions/base.rb', line 33

def validate_against(_definition); end