Class: Lavin::Step
- Inherits:
-
Object
- Object
- Lavin::Step
- Defined in:
- lib/lavin/step.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repeat ⇒ Object
readonly
Returns the value of attribute repeat.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #call(context:) ⇒ Object
-
#initialize(name:, user:, repeat: 1, &block) ⇒ Step
constructor
A new instance of Step.
- #run(context: nil) ⇒ Object
Constructor Details
#initialize(name:, user:, repeat: 1, &block) ⇒ Step
Returns a new instance of Step.
9 10 11 12 13 14 |
# File 'lib/lavin/step.rb', line 9 def initialize(name:, user:, repeat: 1, &block) @name = name @user = user @repeat = repeat @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/lavin/step.rb', line 7 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/lavin/step.rb', line 7 def name @name end |
#repeat ⇒ Object (readonly)
Returns the value of attribute repeat.
7 8 9 |
# File 'lib/lavin/step.rb', line 7 def repeat @repeat end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/lavin/step.rb', line 7 def user @user end |
Instance Method Details
#call(context:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lavin/step.rb', line 23 def call(context:) context.instance_exec(&block) Statistics.register_step(user: user.name, step_name: name) rescue SuccessfulStep, SuccessfulUser => error Statistics.register_step(user: user.name, step_name: name) throw :stop_user if error.is_a? SuccessfulUser rescue IrrecoverableError => error Statistics.register_step(user: user.name, step_name: name, failure: error.) throw :stop_user rescue => error puts "Exception in #{user.name}.#{name} - #{error.class}: #{error.}" Statistics.register_step(user: user.name, step_name: name, failure: error.) end |