moiristo / deep_cloneable

This gem gives every ActiveRecord::Base object the possibility to do a deep clone that includes user specified associations.
MIT License
785 stars 89 forks source link

Block processing isn't in an obvious place #81

Closed davefp closed 7 years ago

davefp commented 7 years ago

From the README:

Pass a block to deep_clone to modify a duped object after duplication My assumption after reading the above was that my block would get executed right before the copy was returned.

In particular, properties excluded with the except parameter would be gone and any value I wrote to those fields would be included in the copy.

This isn't the case, as exclusion happens after the block is invoked.

For now I suggest adding something like the following to the docs:

Note: The block is invoked before properties are excluded

In a future version, I think invoking the block after all other processing would be more valuable.

davefp commented 7 years ago

I'm happy to submit a PR for the documentation change, BTW.

moiristo commented 7 years ago

Hi, thanks for your feedback! I agree that it's in the wrong place. I added the note you specified to the docs.

davefp commented 7 years ago

Brill, thanks!