Module: ServiceOperator::Steps::ClassMethods
- Defined in:
- lib/service_operator/steps.rb
Instance Method Summary collapse
-
#after(name = nil, service: nil, **args, &block) ⇒ Object
Examples.
- #after_steps ⇒ Object
-
#before(name = nil, service: nil, **args, &block) ⇒ Object
Examples.
- #before_steps ⇒ Object
-
#step(name = nil, service: nil, **args, &block) ⇒ Object
Examples.
- #steps ⇒ Object
Instance Method Details
#after(name = nil, service: nil, **args, &block) ⇒ Object
Examples
class MyOperator
include ServiceOperator::Helpers
after :set_finish_time
after :finishing, service: SomeService
after do
puts 'finished'
end
private
def set_finish_time
context.finish_time = Time.now
end
end
89 90 91 |
# File 'lib/service_operator/steps.rb', line 89 def after(name=nil, service: nil, **args, &block) after_steps << Step.new(name: name, service: service, args: args, block: block) end |
#after_steps ⇒ Object
20 21 22 |
# File 'lib/service_operator/steps.rb', line 20 def after_steps @after_steps ||= [] end |
#before(name = nil, service: nil, **args, &block) ⇒ Object
Examples
class MyOperator
include ServiceOperator::Helpers
before :set_start_time
before :initial, service: SomeService
before do
puts 'started'
end
private
def set_start_time
context.start_time = Time.now
end
end
43 44 45 |
# File 'lib/service_operator/steps.rb', line 43 def before(name=nil, service: nil, **args, &block) before_steps << Step.new(name: name, service: service, args: args, block: block) end |
#before_steps ⇒ Object
12 13 14 |
# File 'lib/service_operator/steps.rb', line 12 def before_steps @before_steps ||= [] end |
#step(name = nil, service: nil, **args, &block) ⇒ Object
Examples
class MyOperator
include ServiceOperator::Helpers
step :set_initiated
step :perform_work, service: AnotherService
step do
puts 'going to finish'
end
private
def set_initiated
context.initiated = true
end
end
66 67 68 |
# File 'lib/service_operator/steps.rb', line 66 def step(name=nil, service: nil, **args, &block) steps << Step.new(name: name, service: service, args: args, block: block) end |
#steps ⇒ Object
16 17 18 |
# File 'lib/service_operator/steps.rb', line 16 def steps @steps ||= [] end |