docs/parameters.md in clowne-0.2.0 vs docs/parameters.md in clowne-1.0.0
- old
+ new
@@ -14,11 +14,12 @@
finalize do |_source, record, params|
record.email = params[:email]
end
end
-cloned = UserCloner.call(user, state: :draft, email: 'cloned@example.com')
+operation = UserCloner.call(user, state: :draft, email: 'cloned@example.com')
+cloned = operation.to_record
cloned.email
# => 'cloned@example.com'
```
## Potential Problems
@@ -52,11 +53,11 @@
include_association :profile
# equal to include_association :profile, params: false
end
# Pass all parameters to associations
- trait :params_true do
+ trait :all_params do
include_association :profile, params: true
end
# Filter parameters by key.
# Notice: value by key must be a Hash.
@@ -91,17 +92,17 @@
# Execute:
def get_profile_jsonb(user, trait)
params = { profile: { name: 'John', surname: 'Cena' } }
- cloned = UserCloner.call(user, traits: trait, **params)
+ cloned = UserCloner.call(user, traits: trait, **params).to_record
cloned.profile.jsonb_field
end
get_profile_jsonb(user, :default)
# => {}
-get_profile_jsonb(user, :params_true)
+get_profile_jsonb(user, :all_params)
# => { profile: { name: 'John', surname: 'Cena' } }
get_profile_jsonb(user, :by_key)
# => { name: 'John', surname: 'Cena' }