Sha256: 66f2710936d20a3a5fc9d3435ed1ef731523e280df3cae8e229befebe9f9d939

Contents?: true

Size: 884 Bytes

Versions: 2

Compression:

Stored size: 884 Bytes

Contents

---
id: active_record
title: Active Record
---

Clowne provides an optional ActiveRecord integration which allows you to configure cloners in your models and adds a shortcut to invoke cloners (`#clowne` method).

To enable this integration, you must require `"clowne/adapters/active_record/dsl"` somewhere in your app, e.g., in the initializer:

```ruby
# config/initializers/clowne.rb
require 'clowne/adapters/active_record/dsl'
Clowne.default_adapter = :active_record
```

Now you can specify cloning configs in your AR models:

```ruby
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
```

And then you can clone objects like this:

```ruby
user.clowne(traits: my_traits, **params).to_record
# => <#User id: nil...>
```

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clowne-1.1.0 docs/active_record.md
clowne-1.0.0 docs/active_record.md