Class: Roast::Cog::Registry
- Inherits:
-
Object
- Object
- Roast::Cog::Registry
- Defined in:
- lib/roast/cog/registry.rb
Overview
Registry for managing available cogs in a workflow
Defined Under Namespace
Classes: CogRegistryError, CouldNotDeriveCogNameError
Instance Attribute Summary collapse
-
#cogs ⇒ Object
readonly
Hash mapping cog names to cog classes.
Instance Method Summary collapse
-
#initialize ⇒ Registry
constructor
Initialize a new cog registry with standard cogs.
-
#use(cog_class) ⇒ Object
Register a cog class for use in workflows.
Constructor Details
#initialize ⇒ Registry
Initialize a new cog registry with standard cogs
Automatically registers all system cogs and standard cogs provided by core Roast.
#### See Also
-
‘use`
-
‘cogs`
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/roast/cog/registry.rb', line 22 def initialize @cogs = {} use(SystemCogs::Call) use(SystemCogs::Map) use(SystemCogs::Repeat) use(Cogs::Cmd) use(Cogs::Chat) use(Cogs::Agent) use(Cogs::Ruby) end |
Instance Attribute Details
#cogs ⇒ Object (readonly)
Hash mapping cog names to cog classes
#### See Also
-
‘use`
: Hash[Symbol, singleton(Cog)]
39 40 41 |
# File 'lib/roast/cog/registry.rb', line 39 def cogs @cogs end |
Instance Method Details
#use(cog_class) ⇒ Object
Register a cog class for use in workflows
Adds the provided cog class to the registry, deriving its name from the class name. The cog name is the underscored, demodulized version of the class name (e.g., ‘Roast::Cogs::MyCustomCog` becomes `:my_custom_cog`).
Raises ‘CouldNotDeriveCogNameError` if the cog class name cannot be determined.
#### See Also
-
‘cogs`
: (singleton(Roast::Cog)) -> void
53 54 55 56 |
# File 'lib/roast/cog/registry.rb', line 53 def use(cog_class) name, klass = create_registration(cog_class) cogs[name] = klass end |