Class: Genesis::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/genesis/agent.rb

Overview

Interface for a GenesisAgent Allows subclasess specifying agents in a DSL

Direct Known Subclasses

Echo::Agent, Snmp::Agent

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.agentsObject

Returns the value of attribute agents.



6
7
8
# File 'lib/genesis/agent.rb', line 6

def agents
  @agents
end

Class Method Details

.inherited(subclass) ⇒ Object



15
16
17
18
# File 'lib/genesis/agent.rb', line 15

def inherited(subclass)
  subclass.reset!
  super
end

.register_agent(**kwargs, &block) ⇒ Object Also known as: schedule



7
8
9
# File 'lib/genesis/agent.rb', line 7

def register_agent(**kwargs, &block)
  @agents << { interval: kwargs[:interval] || 60, opts: kwargs, block: block }
end

.reset!Object



11
12
13
# File 'lib/genesis/agent.rb', line 11

def reset!
  @agents = []
end