Class: RubyReactor::Dsl::StepConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_reactor/dsl/step_builder.rb

Direct Known Subclasses

InterruptStepConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ StepConfig

Returns a new instance of StepConfig.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 141

def initialize(config)
  @async_dispatch = config[:async_dispatch]
  @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]
  @retry_config = { max_attempts: 1 }.merge(config[:retry_config] || {})
end

Instance Attribute Details

#args_validatorObject (readonly)

Returns the value of attribute args_validator.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def args_validator
  @args_validator
end

#argumentsObject (readonly)

Returns the value of attribute arguments.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def arguments
  @arguments
end

#async_dispatchObject (readonly)

Returns the value of attribute async_dispatch.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def async_dispatch
  @async_dispatch
end

#compensate_blockObject (readonly)

Returns the value of attribute compensate_block.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def compensate_block
  @compensate_block
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def conditions
  @conditions
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def dependencies
  @dependencies
end

#guardsObject (readonly)

Returns the value of attribute guards.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def guards
  @guards
end

#implObject (readonly)

Returns the value of attribute impl.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def impl
  @impl
end

#nameObject (readonly)

Returns the value of attribute name.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def name
  @name
end

#output_validatorObject (readonly)

Returns the value of attribute output_validator.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def output_validator
  @output_validator
end

#retry_configObject (readonly)

Returns the value of attribute retry_config.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def retry_config
  @retry_config
end

#run_blockObject (readonly)

Returns the value of attribute run_block.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def run_block
  @run_block
end

#undo_blockObject (readonly)

Returns the value of attribute undo_block.



138
139
140
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 138

def undo_block
  @undo_block
end

Instance Method Details

#async_dispatch?Boolean

True for async_step / async_reactor — the step's work leaves this process instead of running inline. RSpec::TestSubject's async: false clears the marker to run the whole reactor in one process.

Returns:



160
161
162
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 160

def async_dispatch?
  !@async_dispatch.nil?
end

#has_impl?Boolean

Returns:



164
165
166
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 164

def has_impl?
  !@impl.nil?
end

#has_run_block?Boolean

Returns:



168
169
170
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 168

def has_run_block?
  !@run_block.nil?
end

#interrupt?Boolean

Returns:



181
182
183
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 181

def interrupt?
  false
end

#retryable?Boolean

Returns:



172
173
174
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 172

def retryable?
  (retry_config[:max_attempts] || 0) > 1
end

#should_run?(context) ⇒ Boolean

Returns:



176
177
178
179
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 176

def should_run?(context)
  @conditions.all? { |condition| condition.call(context) } &&
    @guards.all? { |guard| guard.call(context) }
end