Class: RubyReactor::Dsl::StepConfig
- Inherits:
-
Object
- Object
- RubyReactor::Dsl::StepConfig
- Defined in:
- lib/ruby_reactor/dsl/step_builder.rb
Instance Attribute Summary collapse
-
#args_validator ⇒ Object
readonly
Returns the value of attribute args_validator.
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#async ⇒ Object
readonly
Returns the value of attribute async.
-
#compensate_block ⇒ Object
readonly
Returns the value of attribute compensate_block.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#guards ⇒ Object
readonly
Returns the value of attribute guards.
-
#impl ⇒ Object
readonly
Returns the value of attribute impl.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_validator ⇒ Object
readonly
Returns the value of attribute output_validator.
-
#retry_config ⇒ Object
readonly
Returns the value of attribute retry_config.
-
#run_block ⇒ Object
readonly
Returns the value of attribute run_block.
-
#undo_block ⇒ Object
readonly
Returns the value of attribute undo_block.
Instance Method Summary collapse
- #async? ⇒ Boolean
- #has_impl? ⇒ Boolean
- #has_run_block? ⇒ Boolean
-
#initialize(config) ⇒ StepConfig
constructor
A new instance of StepConfig.
- #retryable? ⇒ Boolean
- #should_run?(context) ⇒ Boolean
Constructor Details
#initialize(config) ⇒ StepConfig
Returns a new instance of StepConfig.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 139 def initialize(config) @name = config[:name] @impl = config[:impl] @arguments = config[:arguments] || {} @run_block = config[:run_block] @compensate_block = config[:compensate_block] @undo_block = config[:undo_block] @conditions = config[:conditions] || [] @guards = config[:guards] || [] @dependencies = config[:dependencies] || [] @args_validator = config[:args_validator] @output_validator = config[:output_validator] @async = config[:async] || false @retry_config = { max_attempts: 1 }.merge(config[:retry_config] || {}) end |
Instance Attribute Details
#args_validator ⇒ Object (readonly)
Returns the value of attribute args_validator.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def args_validator @args_validator end |
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def arguments @arguments end |
#async ⇒ Object (readonly)
Returns the value of attribute async.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def async @async end |
#compensate_block ⇒ Object (readonly)
Returns the value of attribute compensate_block.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def compensate_block @compensate_block end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def conditions @conditions end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def dependencies @dependencies end |
#guards ⇒ Object (readonly)
Returns the value of attribute guards.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def guards @guards end |
#impl ⇒ Object (readonly)
Returns the value of attribute impl.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def impl @impl end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def name @name end |
#output_validator ⇒ Object (readonly)
Returns the value of attribute output_validator.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def output_validator @output_validator end |
#retry_config ⇒ Object (readonly)
Returns the value of attribute retry_config.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def retry_config @retry_config end |
#run_block ⇒ Object (readonly)
Returns the value of attribute run_block.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def run_block @run_block end |
#undo_block ⇒ Object (readonly)
Returns the value of attribute undo_block.
136 137 138 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 136 def undo_block @undo_block end |
Instance Method Details
#async? ⇒ Boolean
163 164 165 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 163 def async? @async end |
#has_impl? ⇒ Boolean
155 156 157 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 155 def has_impl? !@impl.nil? end |
#has_run_block? ⇒ Boolean
159 160 161 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 159 def has_run_block? !@run_block.nil? end |
#retryable? ⇒ Boolean
167 168 169 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 167 def retryable? (retry_config[:max_attempts] || 0) > 1 end |
#should_run?(context) ⇒ Boolean
171 172 173 174 |
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 171 def should_run?(context) @conditions.all? { |condition| condition.call(context) } && @guards.all? { |guard| guard.call(context) } end |