Class: MARS::Runnable
Direct Known Subclasses
AgentStep, Aggregator, Gate, Workflows::Parallel, Workflows::Sequential
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name: self.class.step_name, state: {}, formatter: nil) ⇒ Runnable
constructor
A new instance of Runnable.
- #run(context) ⇒ Object
Methods included from Hooks
included, #run_after_hooks, #run_before_hooks
Constructor Details
#initialize(name: self.class.step_name, state: {}, formatter: nil) ⇒ Runnable
Returns a new instance of Runnable.
23 24 25 26 27 |
# File 'lib/mars/runnable.rb', line 23 def initialize(name: self.class.step_name, state: {}, formatter: nil) @name = name @state = state @formatter = formatter || self.class.formatter&.new || Formatter.new end |
Instance Attribute Details
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
7 8 9 |
# File 'lib/mars/runnable.rb', line 7 def formatter @formatter end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/mars/runnable.rb', line 7 def name @name end |
#state ⇒ Object
Returns the value of attribute state.
8 9 10 |
# File 'lib/mars/runnable.rb', line 8 def state @state end |
Class Method Details
.formatter(klass = nil) ⇒ Object
18 19 20 |
# File 'lib/mars/runnable.rb', line 18 def formatter(klass = nil) klass ? @formatter_class = klass : @formatter_class end |
.step_name ⇒ Object
11 12 13 14 15 16 |
# File 'lib/mars/runnable.rb', line 11 def step_name return @step_name if defined?(@step_name) return unless name name.split("::").last.gsub(/([a-z])([A-Z])/, '\1_\2').downcase end |
Instance Method Details
#run(context) ⇒ Object
29 30 31 |
# File 'lib/mars/runnable.rb', line 29 def run(context) raise NotImplementedError end |