README.md in prosopite-1.0.9 vs README.md in prosopite-1.1.1
- old
+ new
@@ -223,18 +223,26 @@
Prosopite.scan
<code to scan>
Prosopite.finish
```
-or
+In block form the `Prosopite.finish` is called automatically for you at the end of the block:
```ruby
Prosopite.scan do
-<code to scan>
+ <code to scan>
end
```
+The result of the code block is also returned by `Prosopite.scan`, so you can wrap calls as follows:
+
+```ruby
+my_object = Prosopite.scan do
+ MyObjectFactory.create(params)
+end
+```
+
## Pausing and resuming scans
Scans can be paused:
```ruby
@@ -242,9 +250,23 @@
# <code to scan>
Prosopite.pause
# <code that has n+1s>
Prosopite.resume
# <code to scan>
+Prosopite.finish
+```
+
+You can also pause items in a block, and the `Prosopite.resume` will be done
+for you automatically:
+
+```ruby
+Prosopite.scan
+# <code to scan>
+
+result = Prosopite.pause do
+ # <code that has n+1s>
+end
+
Prosopite.finish
```
An example of when you might use this is if you are [testing Active Jobs inline](https://guides.rubyonrails.org/testing.html#testing-jobs),
and don't want to run Prosopite on background job code, just foreground app code. In that case you could write an [Active Job callback](https://edgeguides.rubyonrails.org/active_job_basics.html#callbacks) that pauses the scan while the job is running.