README.md in business_pipeline-0.1.1 vs README.md in business_pipeline-0.1.2
- old
+ new
@@ -223,11 +223,11 @@
puts "Calling process: #{process.class}"
puts "Config is: #{config.inspect}"
puts "Context before call is: #{context.inspect}"
- process.perform
+ process.call
puts "Context after call is: #{context.inspect}"
end
before :some_method
@@ -238,30 +238,32 @@
end
end
```
+**Important:** don’t call `process.perform` inside a Hook, it would trigger the hooks and create an infinite loop.
+
### Hooks execution order
Execution of _around_ hooks will always be the first one. Then the _before_ hooks and to finish the _after_ ones. So writing the following Process
```ruby
class IndexProcess
include BusinessPipeline::Process
around do |process|
puts 'AROUND 1 START'
- process.perform
+ process.call
puts 'AROUND 1 END'
end
before { puts 'BEFORE 1' }
before { puts 'BEFORE 2' }
around do |process|
puts 'AROUND 2 START'
- process.perform
+ process.call
puts 'AROUND 2 END'
end
after { puts 'AFTER 1' }
after { puts 'AFTER 2' }
@@ -288,10 +290,10 @@
If for instance you wanted to wrap every Process in a transaction (which would be a good idea by the way :wink:), you can define it this way:
```ruby
class TransactionWrapping
def call(process, context, config)
- ActiveRecord::Base.transaction { process.perform }
+ ActiveRecord::Base.transaction { process.call }
end
end
class ApplicationProcess
include BusinessPipeline::Process