Class: Expedite::Agent

Inherits:
Object
  • Object
show all
Includes:
Hooks
Defined in:
lib/expedite/agents.rb

Overview

Definition of a Agent

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hooks

#all_hooks, #clear_hooks, #hooks, #register_hook, #run_hook

Constructor Details

#initialize(parent: nil, keep_alive: false) ⇒ Agent

parent

Name of parent agent.

keep_alive

Specifies if the agent should be automatically restarted if it is terminated. Defaults to false.



22
23
24
25
# File 'lib/expedite/agents.rb', line 22

def initialize(parent: nil, keep_alive: false)
  @parent = parent
  @keep_alive = keep_alive
end

Instance Attribute Details

#keep_aliveObject

If set to true, agent will be restarted automatically if it is killed. Defaults to false.



17
18
19
# File 'lib/expedite/agents.rb', line 17

def keep_alive
  @keep_alive
end

#parentObject

Name of the parent agent. This allows you to create agents from an existing agent. Defaults to nil.



12
13
14
# File 'lib/expedite/agents.rb', line 12

def parent
  @parent
end

Instance Method Details

#after(event, &block) ⇒ Object



34
35
36
# File 'lib/expedite/agents.rb', line 34

def after(event, &block)
  register_hook(:"after_#{event}", block)
end

#before(event, &block) ⇒ Object

Register a before event



30
31
32
# File 'lib/expedite/agents.rb', line 30

def before(event, &block)
  register_hook(:"before_#{event}", block)
end