clowne 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -51
- data/.travis.yml +11 -23
- data/Gemfile +9 -9
- data/README.md +8 -7
- data/Rakefile +3 -3
- data/clowne.gemspec +14 -8
- data/docs/.nojekyll +0 -0
- data/docs/.rubocop.yml +8 -2
- data/docs/CNAME +1 -0
- data/docs/README.md +131 -0
- data/docs/_sidebar.md +25 -0
- data/docs/active_record.md +2 -5
- data/docs/after_clone.md +3 -6
- data/docs/after_persist.md +7 -10
- data/docs/architecture.md +2 -5
- data/docs/assets/docsify.min.js +1 -0
- data/docs/assets/prism-ruby.min.js +1 -0
- data/docs/assets/styles.css +348 -0
- data/docs/assets/vue.css +1 -0
- data/docs/clone_mapper.md +2 -5
- data/docs/customization.md +1 -4
- data/docs/exclude_association.md +1 -4
- data/docs/finalize.md +4 -8
- data/docs/from_v02_to_v1.md +2 -10
- data/docs/getting_started.md +171 -0
- data/docs/implicit_cloner.md +1 -4
- data/docs/include_association.md +3 -6
- data/docs/index.html +29 -0
- data/docs/init_as.md +4 -8
- data/docs/inline_configuration.md +1 -4
- data/docs/nullify.md +1 -5
- data/docs/operation.md +3 -6
- data/docs/parameters.md +5 -8
- data/docs/sequel.md +1 -4
- data/docs/supported_adapters.md +3 -6
- data/docs/testing.md +18 -21
- data/docs/traits.md +1 -4
- data/gemfiles/activerecord42.gemfile +5 -5
- data/gemfiles/jruby.gemfile +6 -6
- data/gemfiles/railsmaster.gemfile +6 -6
- data/lib/clowne.rb +11 -11
- data/lib/clowne/adapters/active_record.rb +3 -3
- data/lib/clowne/adapters/active_record/associations.rb +7 -7
- data/lib/clowne/adapters/active_record/associations/base.rb +1 -1
- data/lib/clowne/adapters/active_record/associations/belongs_to.rb +1 -1
- data/lib/clowne/adapters/active_record/associations/has_one.rb +1 -1
- data/lib/clowne/adapters/active_record/resolvers/association.rb +1 -1
- data/lib/clowne/adapters/base.rb +6 -6
- data/lib/clowne/adapters/sequel.rb +7 -7
- data/lib/clowne/adapters/sequel/associations.rb +6 -6
- data/lib/clowne/adapters/sequel/associations/base.rb +2 -2
- data/lib/clowne/adapters/sequel/associations/many_to_many.rb +4 -4
- data/lib/clowne/adapters/sequel/associations/one_to_many.rb +1 -1
- data/lib/clowne/adapters/sequel/associations/one_to_one.rb +1 -1
- data/lib/clowne/adapters/sequel/operation.rb +3 -2
- data/lib/clowne/adapters/sequel/resolvers/after_persist.rb +1 -1
- data/lib/clowne/adapters/sequel/resolvers/association.rb +1 -1
- data/lib/clowne/adapters/sequel/specifications/after_persist_does_not_support.rb +1 -1
- data/lib/clowne/cloner.rb +8 -8
- data/lib/clowne/declarations.rb +15 -15
- data/lib/clowne/declarations/after_clone.rb +1 -1
- data/lib/clowne/declarations/after_persist.rb +1 -1
- data/lib/clowne/declarations/finalize.rb +1 -1
- data/lib/clowne/declarations/include_association.rb +1 -1
- data/lib/clowne/declarations/init_as.rb +1 -1
- data/lib/clowne/declarations/nullify.rb +1 -1
- data/lib/clowne/ext/orm_ext.rb +1 -1
- data/lib/clowne/ext/record_key.rb +1 -1
- data/lib/clowne/ext/string_constantize.rb +1 -1
- data/lib/clowne/ext/yield_self_then.rb +1 -1
- data/lib/clowne/planner.rb +1 -1
- data/lib/clowne/rspec.rb +3 -3
- data/lib/clowne/rspec/clone_association.rb +3 -3
- data/lib/clowne/rspec/clone_associations.rb +2 -2
- data/lib/clowne/rspec/helpers.rb +1 -1
- data/lib/clowne/utils/clone_mapper.rb +1 -1
- data/lib/clowne/utils/operation.rb +3 -3
- data/lib/clowne/utils/params.rb +1 -1
- data/lib/clowne/version.rb +1 -1
- metadata +50 -35
- data/docs/alternatives.md +0 -26
- data/docs/basic_example.md +0 -83
- data/docs/installation.md +0 -46
- data/docs/overview.md +0 -25
- data/docs/web/.gitignore +0 -11
- data/docs/web/README.md +0 -6
- data/docs/web/core/Footer.js +0 -88
- data/docs/web/i18n/en.json +0 -141
- data/docs/web/package.json +0 -14
- data/docs/web/pages/en/help.js +0 -50
- data/docs/web/pages/en/index.js +0 -231
- data/docs/web/pages/en/users.js +0 -47
- data/docs/web/sidebars.json +0 -38
- data/docs/web/siteConfig.js +0 -46
- data/docs/web/static/css/custom.css +0 -235
- data/docs/web/static/fonts/FiraCode-Medium.woff +0 -0
- data/docs/web/static/fonts/FiraCode-Regular.woff +0 -0
- data/docs/web/static/img/favicon/favicon.ico +0 -0
- data/docs/web/yarn.lock +0 -1741
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0815485e47677a65023e13711ad70570b79c97057ad8d09bed83f45aa293f939'
|
4
|
+
data.tar.gz: d1f8a39135462f1bca941515d055f19f44cdf92c0152ea0c49d8dd3f39475fb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 809ecabf16dc071eda96f03853baaa42b5736804864e417e2d9a03ee3d37425b7e01c649cee2a2b8728813ffb09a3a4fb61a59e53ebdbf5f3da0b0a435a91807
|
7
|
+
data.tar.gz: 9c186a3f86f85f2a08eaea4612329a86f104328c99aa561f82a9b42f9b69f50b159f15b1426aec68585aca6f24c937b0967876689b84a0d04a64ac041169c175
|
data/.rubocop.yml
CHANGED
@@ -1,68 +1,28 @@
|
|
1
1
|
require:
|
2
|
-
|
2
|
+
# add after moving docs to another tool
|
3
|
+
- 'standard/cop/semantic_blocks'
|
4
|
+
- 'rubocop-md'
|
5
|
+
|
6
|
+
inherit_gem:
|
7
|
+
standard: config/base.yml
|
8
|
+
|
3
9
|
AllCops:
|
4
10
|
Exclude:
|
5
11
|
- 'bin/**/*'
|
6
12
|
- 'tmp/**/*'
|
7
|
-
- 'docs/web/**/*'
|
8
13
|
- 'vendor/**/*'
|
9
14
|
- 'gemfiles/vendor/**/*'
|
15
|
+
- 'clowne.gemspec'
|
10
16
|
DisplayCopNames: true
|
11
|
-
|
12
|
-
TargetRubyVersion: 2.3
|
17
|
+
TargetRubyVersion: 2.5
|
13
18
|
|
14
19
|
Markdown:
|
15
20
|
WarnInvalid: true
|
16
21
|
|
17
|
-
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
Naming/AccessorMethodName:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Naming/ClassAndModuleCamelCase:
|
24
|
-
Exclude:
|
25
|
-
- 'spec/**/*.rb'
|
26
|
-
|
27
|
-
Naming/UncommunicativeMethodParamName:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
Naming/MemoizedInstanceVariableName:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
Style/TrivialAccessors:
|
34
|
-
Enabled: false
|
35
|
-
|
36
|
-
Metrics/LineLength:
|
37
|
-
Max: 100
|
38
|
-
|
39
|
-
Style/Documentation:
|
40
|
-
Exclude:
|
41
|
-
- 'spec/**/*.rb'
|
42
|
-
- 'README.md'
|
43
|
-
|
44
|
-
Style/SymbolArray:
|
45
|
-
Enabled: false
|
46
|
-
|
47
|
-
Style/FrozenStringLiteralComment:
|
48
|
-
Exclude:
|
49
|
-
- 'spec/**/*.rb'
|
50
|
-
- 'Gemfile'
|
51
|
-
- 'Rakefile'
|
52
|
-
- '*.gemspec'
|
53
|
-
- 'CHANGELOG.md'
|
54
|
-
- 'README.md'
|
55
|
-
|
56
|
-
Metrics/BlockLength:
|
57
|
-
Exclude:
|
58
|
-
- 'spec/**/*.rb'
|
59
|
-
|
60
|
-
Bundler/OrderedGems:
|
61
|
-
Enabled: false
|
62
|
-
|
63
|
-
Gemspec/OrderedDependencies:
|
22
|
+
Standard/SemanticBlocks:
|
64
23
|
Enabled: false
|
65
24
|
|
66
25
|
Lint/Void:
|
67
26
|
Exclude:
|
27
|
+
- 'docs/README.md'
|
68
28
|
- 'README.md'
|
data/.travis.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
+
cache: bundler
|
3
4
|
|
4
5
|
notifications:
|
5
6
|
email: false
|
6
7
|
|
7
8
|
before_install:
|
8
|
-
- gem update --system
|
9
9
|
- gem install bundler
|
10
10
|
|
11
11
|
before_script:
|
@@ -16,40 +16,28 @@ before_script:
|
|
16
16
|
script:
|
17
17
|
- bundle exec rake
|
18
18
|
- if [ "$CC_REPORT" == "true" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
|
19
|
-
- if [ "$DEPLOY_ME" == "true" ]; then (cd ./docs/web && yarn && yarn run build); fi
|
20
19
|
|
21
20
|
matrix:
|
22
21
|
fast_finish: true
|
23
22
|
include:
|
24
23
|
- rvm: ruby-head
|
25
24
|
gemfile: gemfiles/railsmaster.gemfile
|
26
|
-
- rvm: jruby-9.2.
|
25
|
+
- rvm: jruby-9.2.8.0
|
27
26
|
gemfile: gemfiles/jruby.gemfile
|
28
|
-
- rvm:
|
29
|
-
gemfile:
|
30
|
-
- rvm: 2.5
|
27
|
+
- rvm: 2.7
|
28
|
+
gemfile: Gemfile
|
29
|
+
- rvm: 2.6.5
|
31
30
|
gemfile: Gemfile
|
32
|
-
- rvm: 2.
|
31
|
+
- rvm: 2.5.7
|
33
32
|
gemfile: Gemfile
|
34
|
-
|
35
|
-
- CC_REPORT=true
|
36
|
-
- DEPLOY_ME=true
|
37
|
-
- rvm: 2.4.1
|
33
|
+
- rvm: 2.4.9
|
38
34
|
gemfile: gemfiles/activerecord42.gemfile
|
39
|
-
- rvm:
|
35
|
+
- rvm: truffleruby-head
|
40
36
|
gemfile: Gemfile
|
41
37
|
allow_failures:
|
42
38
|
- rvm: ruby-head
|
43
39
|
gemfile: gemfiles/railsmaster.gemfile
|
44
|
-
- rvm: jruby-9.2.
|
40
|
+
- rvm: jruby-9.2.8.0
|
45
41
|
gemfile: gemfiles/jruby.gemfile
|
46
|
-
- rvm:
|
47
|
-
gemfile:
|
48
|
-
deploy:
|
49
|
-
provider: pages
|
50
|
-
skip_cleanup: true
|
51
|
-
github_token: $GITHUB_TOKEN
|
52
|
-
local_dir: "./docs/web/build/clowne"
|
53
|
-
on:
|
54
|
-
branch: master
|
55
|
-
condition: $DEPLOY_ME = true
|
42
|
+
- rvm: truffleruby-head
|
43
|
+
gemfile: Gemfile
|
data/Gemfile
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in clowne.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem
|
6
|
+
gem "pry-byebug", platform: :mri
|
7
7
|
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
8
|
+
gem "sqlite3", "~> 1.4.1", platform: :ruby
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 50.0", platform: :jruby
|
10
|
+
gem "jdbc-sqlite3", platform: :jruby
|
11
11
|
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
12
|
+
gem "activerecord", "~> 5.2"
|
13
|
+
gem "sequel", ">= 5.0"
|
14
|
+
gem "simplecov"
|
15
15
|
|
16
|
-
local_gemfile =
|
16
|
+
local_gemfile = "Gemfile.local"
|
17
17
|
|
18
18
|
if File.exist?(local_gemfile)
|
19
19
|
eval(File.read(local_gemfile)) # rubocop:disable Security/Eval
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/clowne.svg)](https://badge.fury.io/rb/clowne)
|
2
|
-
[![Build Status](https://travis-ci.org/
|
3
|
-
[![Test Coverage](https://codeclimate.com/
|
2
|
+
[![Build Status](https://travis-ci.org/clowne-rb/clowne.svg?branch=master)](https://travis-ci.org/clowne-rb/clowne)
|
3
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/9143c4f91e9d1d2a4bd1/test_coverage)](https://codeclimate.com/github/clowne-rb/clowne/test_coverage)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/9143c4f91e9d1d2a4bd1/maintainability)](https://codeclimate.com/github/clowne-rb/clowne/maintainability)
|
4
5
|
[![Docs](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://clowne.evilmartians.io)
|
5
6
|
|
6
7
|
# Clowne
|
@@ -26,7 +27,7 @@ gem install clowne
|
|
26
27
|
Or add this line to your application's Gemfile:
|
27
28
|
|
28
29
|
```ruby
|
29
|
-
gem
|
30
|
+
gem "clowne"
|
30
31
|
```
|
31
32
|
|
32
33
|
## Quick Start
|
@@ -86,7 +87,7 @@ Now you can use `UserCloner` to clone existing records:
|
|
86
87
|
user = User.last
|
87
88
|
# => <#User id: 1, login: 'clown', email: 'clown@circus.example.com'>
|
88
89
|
|
89
|
-
operation = UserCloner.call(user, email:
|
90
|
+
operation = UserCloner.call(user, email: "fake@example.com")
|
90
91
|
# => <#Clowne::Utils::Operation...>
|
91
92
|
|
92
93
|
operation.to_record
|
@@ -116,14 +117,14 @@ Take a look at our [documentation](https://clowne.evilmartians.io) for more info
|
|
116
117
|
|
117
118
|
Adapter |1:1 |*:1 | 1:M | M:M |
|
118
119
|
------------------------------------------|------------|------------|-------------|-------------------------|
|
119
|
-
[Active Record](https://clowne.evilmartians.io
|
120
|
-
[Sequel](https://clowne.evilmartians.io
|
120
|
+
[Active Record](https://clowne.evilmartians.io/#/active_record) | has_one | belongs_to | has_many | has_and_belongs_to|
|
121
|
+
[Sequel](https://clowne.evilmartians.io/#/sequel) | one_to_one | - | one_to_many | many_to_many |
|
121
122
|
|
122
123
|
## Maintainers
|
123
124
|
|
124
125
|
- [Vladimir Dementyev](https://github.com/palkan)
|
125
126
|
|
126
|
-
- [Sverchkov
|
127
|
+
- [Nikolay Sverchkov](https://github.com/ssnickolay)
|
127
128
|
|
128
129
|
## License
|
129
130
|
|
data/Rakefile
CHANGED
data/clowne.gemspec
CHANGED
@@ -8,23 +8,29 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['Vladimir Dementyev', 'Sverchkov Nikolay']
|
9
9
|
spec.email = ['palkan@evilmartians.com', 'ssnikolay@gmail.com']
|
10
10
|
|
11
|
-
spec.summary = 'A flexible gem for cloning your models
|
11
|
+
spec.summary = 'A flexible gem for cloning your models'
|
12
12
|
spec.description = 'A flexible gem for cloning your models.'
|
13
|
-
spec.homepage = 'https://github.com/
|
13
|
+
spec.homepage = 'https://github.com/clowne-rb/clowne'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
17
|
f.match(%r{^(test|spec|features)/})
|
18
18
|
end
|
19
|
-
spec.
|
20
|
-
|
19
|
+
spec.metadata = {
|
20
|
+
"bug_tracker_uri" => "http://github.com/clowne-rb/clowne/issues",
|
21
|
+
"changelog_uri" => "https://github.com/clowne-rb/clowne/blob/master/CHANGELOG.md",
|
22
|
+
"documentation_uri" => "https://clowne.evilmartians.io/",
|
23
|
+
"homepage_uri" => "https://clowne.evilmartians.io/",
|
24
|
+
"source_code_uri" => "http://github.com/clowne-rb/clowne"
|
25
|
+
}
|
21
26
|
spec.require_paths = ['lib']
|
22
27
|
|
23
28
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
24
|
-
spec.add_development_dependency 'rake', '~>
|
29
|
+
spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
|
25
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
31
|
spec.add_development_dependency 'factory_bot', '~> 4.8'
|
27
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
28
|
-
spec.add_development_dependency 'rubocop-md', '~> 0.
|
29
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 1.
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.75.0'
|
33
|
+
spec.add_development_dependency 'rubocop-md', '~> 0.3.0'
|
34
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.36.0'
|
35
|
+
spec.add_development_dependency 'standard', '~> 0.1.5'
|
30
36
|
end
|
data/docs/.nojekyll
ADDED
File without changes
|
data/docs/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
inherit_gem:
|
2
|
+
standard: config/base.yml
|
3
3
|
|
4
4
|
Lint/Void:
|
5
5
|
Exclude:
|
@@ -8,5 +8,11 @@ Lint/Void:
|
|
8
8
|
Metrics/AbcSize:
|
9
9
|
Enabled: false
|
10
10
|
|
11
|
+
Standard/SemanticBlocks:
|
12
|
+
Enabled: false
|
13
|
+
|
11
14
|
Metrics/BlockLength:
|
12
15
|
Enabled: false
|
16
|
+
|
17
|
+
Metrics/LineLength:
|
18
|
+
Enabled: false
|
data/docs/CNAME
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
clowne.evilmartians.io
|
data/docs/README.md
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/clowne.svg)](https://badge.fury.io/rb/clowne)
|
2
|
+
[![Build Status](https://travis-ci.org/clowne-rb/clowne.svg?branch=master)](https://travis-ci.org/clowne-rb/clowne)
|
3
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/9143c4f91e9d1d2a4bd1/test_coverage)](https://codeclimate.com/github/clowne-rb/clowne/test_coverage)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/9143c4f91e9d1d2a4bd1/maintainability)](https://codeclimate.com/github/clowne-rb/clowne/maintainability)
|
5
|
+
[![Docs](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://clowne.evilmartians.io)
|
6
|
+
|
7
|
+
# Clowne
|
8
|
+
|
9
|
+
A flexible gem for cloning your models. Clowne focuses on ease of use and provides the ability to connect various ORM adapters.
|
10
|
+
|
11
|
+
📖 Read [Evil Martians Chronicles](https://evilmartians.com/chronicles/clowne-clone-ruby-models-with-a-smile) to learn about possible use cases.
|
12
|
+
|
13
|
+
📑 [Documentation](https://clowne.evilmartians.io)
|
14
|
+
|
15
|
+
<a href="https://evilmartians.com/">
|
16
|
+
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
17
|
+
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
To install Clowne with RubyGems:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem install clowne
|
25
|
+
```
|
26
|
+
|
27
|
+
Or add this line to your application's Gemfile:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem "clowne"
|
31
|
+
```
|
32
|
+
|
33
|
+
## Quick Start
|
34
|
+
|
35
|
+
Assume that you have the following model:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
class User < ActiveRecord::Base
|
39
|
+
# create_table :users do |t|
|
40
|
+
# t.string :login
|
41
|
+
# t.string :email
|
42
|
+
# t.timestamps null: false
|
43
|
+
# end
|
44
|
+
|
45
|
+
has_one :profile
|
46
|
+
has_many :posts
|
47
|
+
end
|
48
|
+
|
49
|
+
class Profile < ActiveRecord::Base
|
50
|
+
# create_table :profiles do |t|
|
51
|
+
# t.string :name
|
52
|
+
# end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Post < ActiveRecord::Base
|
56
|
+
# create_table :posts
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
Let's declare our cloners first:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
class UserCloner < Clowne::Cloner
|
64
|
+
adapter :active_record
|
65
|
+
|
66
|
+
include_association :profile, clone_with: SpecialProfileCloner
|
67
|
+
include_association :posts
|
68
|
+
|
69
|
+
nullify :login
|
70
|
+
|
71
|
+
# params here is an arbitrary Hash passed into cloner
|
72
|
+
finalize do |_source, record, params|
|
73
|
+
record.email = params[:email]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class SpecialProfileCloner < Clowne::Cloner
|
78
|
+
adapter :active_record
|
79
|
+
|
80
|
+
nullify :name
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
Now you can use `UserCloner` to clone existing records:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
user = User.last
|
88
|
+
# => <#User id: 1, login: 'clown', email: 'clown@circus.example.com'>
|
89
|
+
|
90
|
+
operation = UserCloner.call(user, email: "fake@example.com")
|
91
|
+
# => <#Clowne::Utils::Operation...>
|
92
|
+
|
93
|
+
operation.to_record
|
94
|
+
# => <#User id: nil, login: nil, email: 'fake@example.com'>
|
95
|
+
|
96
|
+
operation.persist!
|
97
|
+
# => true
|
98
|
+
|
99
|
+
cloned = operation.to_record
|
100
|
+
# => <#User id: 2, login: nil, email: 'fake@example.com'>
|
101
|
+
|
102
|
+
cloned.login
|
103
|
+
# => nil
|
104
|
+
cloned.email
|
105
|
+
# => "fake@example.com"
|
106
|
+
|
107
|
+
# associations:
|
108
|
+
cloned.posts.count == user.posts.count
|
109
|
+
# => true
|
110
|
+
cloned.profile.name
|
111
|
+
# => nil
|
112
|
+
```
|
113
|
+
|
114
|
+
Take a look at our [documentation](https://clowne.evilmartians.io) for more info!
|
115
|
+
|
116
|
+
### Supported ORM adapters
|
117
|
+
|
118
|
+
Adapter |1:1 |*:1 | 1:M | M:M |
|
119
|
+
------------------------------------------|------------|------------|-------------|-------------------------|
|
120
|
+
[Active Record](active_record) | has_one | belongs_to | has_many | has_and_belongs_to|
|
121
|
+
[Sequel](sequel) | one_to_one | - | one_to_many | many_to_many |
|
122
|
+
|
123
|
+
## Maintainers
|
124
|
+
|
125
|
+
- [Vladimir Dementyev](https://github.com/palkan)
|
126
|
+
|
127
|
+
- [Nikolay Sverchkov](https://github.com/ssnickolay)
|
128
|
+
|
129
|
+
## License
|
130
|
+
|
131
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/docs/_sidebar.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
* [Getting Started](getting_started.md)
|
2
|
+
* DSL
|
3
|
+
* [Operation](operation.md)
|
4
|
+
* [Include Association](include_association.md)
|
5
|
+
* [Exclude Association](exclude_association.md)
|
6
|
+
* [Nullify Attributes](nullify.md)
|
7
|
+
* [Finalization](finalize.md)
|
8
|
+
* [After Clone](after_clone.md)
|
9
|
+
* [After Persist](after_persist.md)
|
10
|
+
* [Initialize Cloning Target](init_as.md)
|
11
|
+
* [Traits](traits.md)
|
12
|
+
* [Parameters](parameters.md)
|
13
|
+
* Adapters
|
14
|
+
* [Supported Adapters](supported_adapters.md)
|
15
|
+
* [ActiveRecord](active_record.md)
|
16
|
+
* [Sequel](sequel.md)
|
17
|
+
* Advanced Options
|
18
|
+
* [Implicit Cloner](implicit_cloner.md)
|
19
|
+
* [Inline Configuration](inline_configuration.md)
|
20
|
+
* [Clone mapper](clone_mapper.md)
|
21
|
+
* [Architecture](architecture.md)
|
22
|
+
* [Testing](testing.md)
|
23
|
+
* [Customization](customization.md)
|
24
|
+
* Upgrade Notes
|
25
|
+
* [From v0.2.x to v1.0.0](from_v02_to_v1.md)
|