{"action":"created","issue":{"url":"https://api.github.com/repos/palkan/clowne/issues/15","repository_url":"https://api.github.com/repos/palkan/clowne","labels_url":"https://api.github.com/repos/palkan/clowne/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/palkan/clowne/issues/15/comments","events_url":"https://api.github.com/repos/palkan/clowne/issues/15/events","html_url":"https://github.com/palkan/clowne/issues/15","id":291882127,"number":15,"title":"Nested params","user":{"login":"palkan","id":1516722,"avatar_url":"https://avatars2.githubusercontent.com/u/1516722?v=4","gravatar_id":"","url":"https://api.github.com/users/palkan","html_url":"https://github.com/palkan","followers_url":"https://api.github.com/users/palkan/followers","following_url":"https://api.github.com/users/palkan/following{/other_user}","gists_url":"https://api.github.com/users/palkan/gists{/gist_id}","starred_url":"https://api.github.com/users/palkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palkan/subscriptions","organizations_url":"https://api.github.com/users/palkan/orgs","repos_url":"https://api.github.com/users/palkan/repos","events_url":"https://api.github.com/users/palkan/events{/privacy}","received_events_url":"https://api.github.com/users/palkan/received_events","type":"User","site_admin":false},"labels":[{"id":729527037,"url":"https://api.github.com/repos/palkan/clowne/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":{"login":"ssnickolay","id":2331796,"avatar_url":"https://avatars0.githubusercontent.com/u/2331796?v=4","gravatar_id":"","url":"https://api.github.com/users/ssnickolay","html_url":"https://github.com/ssnickolay","followers_url":"https://api.github.com/users/ssnickolay/followers","following_url":"https://api.github.com/users/ssnickolay/following{/other_user}","gists_url":"https://api.github.com/users/ssnickolay/gists{/gist_id}","starred_url":"https://api.github.com/users/ssnickolay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssnickolay/subscriptions","organizations_url":"https://api.github.com/users/ssnickolay/orgs","repos_url":"https://api.github.com/users/ssnickolay/repos","events_url":"https://api.github.com/users/ssnickolay/events{/privacy}","received_events_url":"https://api.github.com/users/ssnickolay/received_events","type":"User","site_admin":false},"assignees":[{"login":"ssnickolay","id":2331796,"avatar_url":"https://avatars0.githubusercontent.com/u/2331796?v=4","gravatar_id":"","url":"https://api.github.com/users/ssnickolay","html_url":"https://github.com/ssnickolay","followers_url":"https://api.github.com/users/ssnickolay/followers","following_url":"https://api.github.com/users/ssnickolay/following{/other_user}","gists_url":"https://api.github.com/users/ssnickolay/gists{/gist_id}","starred_url":"https://api.github.com/users/ssnickolay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssnickolay/subscriptions","organizations_url":"https://api.github.com/users/ssnickolay/orgs","repos_url":"https://api.github.com/users/ssnickolay/repos","events_url":"https://api.github.com/users/ssnickolay/events{/privacy}","received_events_url":"https://api.github.com/users/ssnickolay/received_events","type":"User","site_admin":false}],"milestone":null,"comments":8,"created_at":"2018-01-26T12:03:51Z","updated_at":"2018-02-16T06:28:25Z","closed_at":null,"author_association":"OWNER","body":"Currently, we had an effect of _params shadowing_: nested cloner could rely on the same params as the top-level ones, but they must not know about each other (more precisely, children cloners must not know about parent cloners).\r\n\r\nWe need a way to control how `params` are passed to associations cloners, e.g.:\r\n\r\n```ruby\r\n# just pass params as is (current behaviour)\r\ninclude_association :users, params: true\r\n\r\n# use custom block to prepare params\r\ninclude_association :users, params: ->(params) { params[:data] }\r\n\r\n# or use a key\r\ninclude_association :profile, params: :profile\r\n\r\n# usage\r\nUserCloner.call(user, profile: { reset: true })\r\n```\r\n\r\nI also propose to **not proxy params** by default to the underlying cloners."},"comment":{"url":"https://api.github.com/repos/palkan/clowne/issues/comments/366154788","html_url":"https://github.com/palkan/clowne/issues/15#issuecomment-366154788","issue_url":"https://api.github.com/repos/palkan/clowne/issues/15","id":366154788,"user":{"login":"ssnickolay","id":2331796,"avatar_url":"https://avatars0.githubusercontent.com/u/2331796?v=4","gravatar_id":"","url":"https://api.github.com/users/ssnickolay","html_url":"https://github.com/ssnickolay","followers_url":"https://api.github.com/users/ssnickolay/followers","following_url":"https://api.github.com/users/ssnickolay/following{/other_user}","gists_url":"https://api.github.com/users/ssnickolay/gists{/gist_id}","starred_url":"https://api.github.com/users/ssnickolay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssnickolay/subscriptions","organizations_url":"https://api.github.com/users/ssnickolay/orgs","repos_url":"https://api.github.com/users/ssnickolay/repos","events_url":"https://api.github.com/users/ssnickolay/events{/privacy}","received_events_url":"https://api.github.com/users/ssnickolay/received_events","type":"User","site_admin":false},"created_at":"2018-02-16T06:28:25Z","updated_at":"2018-02-16T06:28:25Z","author_association":"COLLABORATOR","body":"@palkan I am a bit confused...\r\n\r\n```\r\nclass SomeCloner < Clowne::Cloner\r\n  include_association :users, params: :foo\r\nend\r\n\r\ncloned1 = SomeCloner.call(record, foo: 1, bar: 2)\r\ncloned2 = SomeCloner.call(record, foo: {name: 'John', surename: 'Cena'}, bar: 2)\r\n```\r\nWhat you expected as a nested parameters? In current realisation I'm trying to pass `params.fetch(:foo)` to cloned association, buts it's not correct when `params[:foo]` not a Hash (like for cloned1)...It seems that we can implement only \"slice behaviour\" (params.slice(:foo) instead of params.fetch(:foo))...or some kind of hybrid option, but I'm not sure that it will be understandable.\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"ssnickolay"}}