Module: Flowy::Concern::ClassMethods
- Defined in:
- lib/flowy/concern.rb
Instance Method Summary collapse
- #_flowy_after_hooks ⇒ Object
- #_flowy_around_hooks ⇒ Object
- #_flowy_before_hooks ⇒ Object
- #_flowy_steps ⇒ Object
-
#after_step(&block) ⇒ Object
Block signature: |step_name, result|.
-
#around_step(&block) ⇒ Object
Block signature: |step_name, previous_result, &call|.
-
#before_step(&block) ⇒ Object
Block signature: |step_name, previous_result|.
- #failure(**kwargs) ⇒ Object
-
#step(name, on_error: nil, before_step: nil, after_step: nil, around_step: nil, **opts) ⇒ Object
‘rescue:` is captured via **opts because `rescue` is a Ruby reserved word and cannot be referenced as a bare local variable inside a method.
- #success(**kwargs) ⇒ Object
- #tap_step(name, before_step: nil, after_step: nil, around_step: nil) ⇒ Object
Instance Method Details
#_flowy_after_hooks ⇒ Object
117 118 119 |
# File 'lib/flowy/concern.rb', line 117 def _flowy_after_hooks @_flowy_after_hooks ||= [] end |
#_flowy_around_hooks ⇒ Object
109 110 111 |
# File 'lib/flowy/concern.rb', line 109 def _flowy_around_hooks @_flowy_around_hooks ||= [] end |
#_flowy_before_hooks ⇒ Object
113 114 115 |
# File 'lib/flowy/concern.rb', line 113 def _flowy_before_hooks @_flowy_before_hooks ||= [] end |
#_flowy_steps ⇒ Object
90 91 92 |
# File 'lib/flowy/concern.rb', line 90 def _flowy_steps @_flowy_steps ||= [] end |
#after_step(&block) ⇒ Object
Block signature: |step_name, result|
105 106 107 |
# File 'lib/flowy/concern.rb', line 105 def after_step(&block) _flowy_after_hooks << block end |
#around_step(&block) ⇒ Object
Block signature: |step_name, previous_result, &call|
95 96 97 |
# File 'lib/flowy/concern.rb', line 95 def around_step(&block) _flowy_around_hooks << block end |
#before_step(&block) ⇒ Object
Block signature: |step_name, previous_result|
100 101 102 |
# File 'lib/flowy/concern.rb', line 100 def before_step(&block) _flowy_before_hooks << block end |
#failure(**kwargs) ⇒ Object
60 61 62 |
# File 'lib/flowy/concern.rb', line 60 def failure(**kwargs) Flowy::Result.failure(**kwargs) end |
#step(name, on_error: nil, before_step: nil, after_step: nil, around_step: nil, **opts) ⇒ Object
‘rescue:` is captured via **opts because `rescue` is a Ruby reserved word and cannot be referenced as a bare local variable inside a method.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/flowy/concern.rb', line 66 def step(name, on_error: nil, before_step: nil, after_step: nil, around_step: nil, **opts) unknown = opts.keys - [:rescue] raise ArgumentError, "unknown keyword: #{unknown.first}" if unknown.any? _flowy_steps << Flowy::Concern._build_step_def( name, rescue: Array(opts[:rescue]), on_error: on_error, before_step: before_step, after_step: after_step, around_step: around_step ) end |
#success(**kwargs) ⇒ Object
56 57 58 |
# File 'lib/flowy/concern.rb', line 56 def success(**kwargs) Flowy::Result.success(**kwargs) end |
#tap_step(name, before_step: nil, after_step: nil, around_step: nil) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/flowy/concern.rb', line 80 def tap_step(name, before_step: nil, after_step: nil, around_step: nil) _flowy_steps << Flowy::Concern._build_step_def( name, tap: true, before_step: before_step, after_step: after_step, around_step: around_step ) end |