Class: Flow::Base
- Inherits:
-
Object
- Object
- Flow::Base
- Defined in:
- lib/flow-lite.rb
Overview
base class for flow class (auto)-constructed/build from flowfile
Class Method Summary collapse
Instance Method Summary collapse
-
#step(name) ⇒ Object
run step by symbol/name (e.g. step :hello - etc.).
Class Method Details
.define_step(name_or_names, &block) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/flow-lite.rb', line 47 def self.define_step( name_or_names, &block ) names = if name_or_names.is_a?( Array ) name_or_names else [name_or_names] ## assume single symbol (name); wrap in array end names = names.map {|name| name.to_sym } ## make sure we always use symbols name = names[0] puts "[flow] adding step >#{name}<..." define_method( :"step_#{name}", &block ) alt_names = names[1..-1] alt_names.each do |alt_name| puts "[flow] adding alias >#{alt_name}< for >#{name}<..." alias_method( :"step_#{alt_name}", :"step_#{name}" ) end end |
.step_methods ⇒ Object
method step
81 82 83 84 85 86 87 |
# File 'lib/flow-lite.rb', line 81 def self.step_methods names = instance_methods.reduce([]) do |names, name| names << $1.to_sym if name =~ /^step_(.+)/ names end names end |
Instance Method Details
#step(name) ⇒ Object
run step by symbol/name (e.g. step :hello - etc.)
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/flow-lite.rb', line 70 def step( name ) name = :"step_#{name}" ## note: make sure we always use symbols if respond_to?( name ) send( name ) else puts "!! ERROR: step definition >#{name}< not found; cannot run/execute - known (defined) steps include:" pp self.class.step_methods #=> e.g. [:hello, ...] exit 1 end end |