Sha256: b875cfbd5ef5fee4a474c4147254eb2614383368f38f28dd5ce52125d0a8b1d8
Contents?: true
Size: 775 Bytes
Versions: 3
Compression:
Stored size: 775 Bytes
Contents
# Inline Configuration You can also enhance the cloner configuration inline (i.e., add declarations dynamically): ```ruby operation = UserCloner.call(User.last) do exclude_association :profile finalize do |source, record| record.email = "clone_of_#{source.email}" end end cloned = operation.to_record cloned.email # => "clone_of_john@example.com" # associations: cloned.posts.size == User.last.posts.size # => true cloned.profile # => nil ``` Inline enhancement doesn't affect the _global_ configuration so that you can use it without any fear. Thus it's also possible to clone objects without any cloner classes at all by using `Clowne::Cloner`: ```ruby cloned = Clowne::Cloner.call(user) do # anything you want! end.to_record cloned # => <#User.. ```
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clowne-1.4.0 | docs/inline_configuration.md |
clowne-1.3.0 | docs/inline_configuration.md |
clowne-1.2.0 | docs/inline_configuration.md |