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.



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 125

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_validatorObject (readonly)

Returns the value of attribute args_validator.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def args_validator
  @args_validator
end

#argumentsObject (readonly)

Returns the value of attribute arguments.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def arguments
  @arguments
end

#asyncObject (readonly)

Returns the value of attribute async.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def async
  @async
end

#compensate_blockObject (readonly)

Returns the value of attribute compensate_block.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def compensate_block
  @compensate_block
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def conditions
  @conditions
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def dependencies
  @dependencies
end

#guardsObject (readonly)

Returns the value of attribute guards.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def guards
  @guards
end

#implObject (readonly)

Returns the value of attribute impl.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def impl
  @impl
end

#nameObject (readonly)

Returns the value of attribute name.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def name
  @name
end

#output_validatorObject (readonly)

Returns the value of attribute output_validator.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def output_validator
  @output_validator
end

#retry_configObject (readonly)

Returns the value of attribute retry_config.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def retry_config
  @retry_config
end

#run_blockObject (readonly)

Returns the value of attribute run_block.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def run_block
  @run_block
end

#undo_blockObject (readonly)

Returns the value of attribute undo_block.



122
123
124
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 122

def undo_block
  @undo_block
end

Instance Method Details

#async?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 149

def async?
  @async
end

#has_impl?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 141

def has_impl?
  !@impl.nil?
end

#has_run_block?Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 145

def has_run_block?
  !@run_block.nil?
end

#interrupt?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 162

def interrupt?
  false
end

#retryable?Boolean

Returns:

  • (Boolean)


153
154
155
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 153

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

#should_run?(context) ⇒ Boolean

Returns:

  • (Boolean)


157
158
159
160
# File 'lib/ruby_reactor/dsl/step_builder.rb', line 157

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