docs/finalize.md in clowne-1.1.0 vs docs/finalize.md in clowne-1.2.0
- old
+ new
@@ -1,17 +1,13 @@
----
-id: finalize
-title: Finalization
-sidebar_label: Finalize
----
+# Finalization
To apply custom transformations to the cloned record, you can use the `finalize` declaration:
```ruby
class UserCloner < Clowne::Cloner
finalize do |_source, record, _params|
- record.name = 'This is copy!'
+ record.name = "This is copy!"
end
trait :change_email do
finalize do |_source, record, params|
record.email = params[:email]
@@ -20,16 +16,16 @@
end
cloned = UserCloner.call(user).to_record
cloned.name
# => 'This is copy!'
-cloned.email == 'clone@example.com'
+cloned.email == "clone@example.com"
# => false
cloned2 = UserCloner.call(user, traits: :change_email).to_record
cloned2.name
# => 'This is copy!'
cloned2.email
# => 'clone@example.com'
```
-Finalization blocks are called at the end of the [cloning process](execution_order.md).
+Finalization blocks are called at the end of the [cloning process](getting_started?id=execution-order).