Sha256: c58546534a660bad290e2e7e957c3b578d9cb7711db4897928a0bddf75ecec6d
Contents?: true
Size: 813 Bytes
Versions: 2
Compression:
Stored size: 813 Bytes
Contents
--- id: inline_configuration title: 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clowne-1.1.0 | docs/inline_configuration.md |
clowne-1.0.0 | docs/inline_configuration.md |