clowne-rb / clowne

A flexible gem for cloning models
https://clowne.evilmartians.io
MIT License
316 stars 18 forks source link

Add ActiveRecord DSL #7

Closed palkan closed 6 years ago

palkan commented 6 years ago

To write things like this:

class User < ActiveRecord::Base
  clowne_config do
    include_associations :profile

    nullify :email

    # whatever available for your cloners,
    # active_record adapter is set implicitly here
  end
end

cloned_user = user.clowne(traits: my_traits, **params)
# it's just a shortcut for
cloned_user = user.class.cloner_class.call(user, *args)

This is an optional feature, should be explicitly enabled (required).