Sha256: f367fa42ebe763952350e3399233cea7d9421193673a38b2f9c9ad21a886aa34

Contents?: true

Size: 625 Bytes

Versions: 2

Compression:

Stored size: 625 Bytes

Contents

---
id: nullify
title: Nullify Attributes
sidebar_label: Nullify
---

To set a bunch of attributes to `nil` you can use the `nullify` declaration:

```ruby
class User < ActiveRecord::Base
  # t.string :name
  # t.string :surname
  # t.string :email
end

class UserCloner < Clowne::Cloner
  nullify :name, :email

  trait :nullify_surname do
    nullify :surname
  end
end

clone = UserCloner.call(user).to_record
clone.name.nil?
# => true
clone.email.nil?
# => true
clone.surname.nil?
# => false

clone2 = UserCloner.call(user, traits: :nullify_surname).to_record
clone2.name.nil?
# => true
clone2.surname.nil?
# => true
```

Version data entries

2 entries across 2 versions & 1 rubygems

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