Class: Roast::SystemCog

Inherits:
Cog
  • Object
show all
Defined in:
lib/roast/system_cog.rb,
lib/roast/system_cog/params.rb

Defined Under Namespace

Classes: Params

Instance Attribute Summary

Attributes inherited from Cog

#name, #output

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Cog

#anonymous?, config_class, #failed?, generate_fallback_name, input_class, #run!, #skipped?, #started?, #stopped?, #succeeded?, #type, #wait

Constructor Details

#initialize(name, cog_input_proc, anonymous:, &on_execute) ⇒ SystemCog

: (Symbol, ^(Cog::Input) -> untyped, anonymous: bool) { (Cog::Input, Cog::Config) -> Cog::Output } -> void



22
23
24
25
# File 'lib/roast/system_cog.rb', line 22

def initialize(name, cog_input_proc, anonymous:, &on_execute)
  super(name, cog_input_proc, anonymous:)
  @on_execute = on_execute
end

Class Method Details

.params_classObject

: () -> singleton(SystemCog::Params)



8
9
10
# File 'lib/roast/system_cog.rb', line 8

def params_class
  @params_class ||= find_child_params_or_default
end

Instance Method Details

#execute(input) ⇒ Object

: (Cog::Input) -> Cog::Output



28
29
30
31
32
# File 'lib/roast/system_cog.rb', line 28

def execute(input)
  # The `on_execute` callback allows a system cog to pass its execution back to the ExecutionManager
  # for special handling.
  @on_execute.call(input, @config)
end