amoeba 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +4 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +17 -0
- data/.travis.yml +13 -5
- data/Appraisals +24 -0
- data/Gemfile +6 -4
- data/README.md +134 -44
- data/Rakefile +2 -2
- data/amoeba.gemspec +20 -15
- data/defaults.reek +11 -0
- data/gemfiles/activerecord_3.2.gemfile +17 -0
- data/gemfiles/activerecord_4.0.gemfile +17 -0
- data/gemfiles/activerecord_4.1.gemfile +17 -0
- data/gemfiles/activerecord_4.2.gemfile +17 -0
- data/gemfiles/activerecord_head.gemfile +23 -0
- data/lib/amoeba.rb +13 -522
- data/lib/amoeba/class_methods.rb +23 -0
- data/lib/amoeba/cloner.rb +168 -0
- data/lib/amoeba/config.rb +172 -0
- data/lib/amoeba/instance_methods.rb +37 -0
- data/lib/amoeba/macros.rb +14 -0
- data/lib/amoeba/macros/base.rb +26 -0
- data/lib/amoeba/macros/has_and_belongs_to_many.rb +19 -0
- data/lib/amoeba/macros/has_many.rb +42 -0
- data/lib/amoeba/macros/has_one.rb +15 -0
- data/lib/amoeba/version.rb +1 -1
- data/spec/lib/amoeba_spec.rb +180 -87
- data/spec/spec_helper.rb +23 -4
- data/spec/support/data.rb +73 -73
- data/spec/support/models.rb +132 -28
- data/spec/support/schema.rb +69 -42
- metadata +38 -29
- data/.ruby-version +0 -1
- data/gemfiles/Gemfile.activerecord-3.2.x +0 -11
- data/gemfiles/Gemfile.activerecord-4.0.x +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef5bca881e5bca87a026e6ec8c6094df2542013
|
4
|
+
data.tar.gz: c452e76e155190c56519de94abf924534ad8b746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7db1e43070c41e05c211962fc7d720b3cecc9ba681f8302b8ba6daae29b6fa94390adff0863970b394a9032b45471cb231227ecd2670039e83f2799884ec6be4
|
7
|
+
data.tar.gz: 850f23a3ae73ab859cff8540110f668e5b54d06757bb6954fed09a61f7c681ea7114c292f755d50f3563318b184d5e912a533b90b155f47aecbedc09c9a51b22
|
data/.cane
ADDED
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- '**/Rakefile'
|
4
|
+
Exclude:
|
5
|
+
- 'spec/**/*'
|
6
|
+
Metrics/LineLength:
|
7
|
+
Max: 99
|
8
|
+
Style/FileName:
|
9
|
+
Enabled: false
|
10
|
+
Style/ModuleFunction:
|
11
|
+
Enabled: false
|
12
|
+
Style/Encoding:
|
13
|
+
Enabled: false
|
14
|
+
Documentation:
|
15
|
+
Enabled: false
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 15
|
data/.travis.yml
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.9.3
|
4
|
-
- 1.9.2
|
5
3
|
- 2.0.0
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
6
|
- ruby-head
|
7
7
|
- jruby-19mode # JRuby in 1.9 mode
|
8
|
-
- rbx-
|
8
|
+
- rbx-2
|
9
9
|
gemfile:
|
10
|
-
- gemfiles/
|
11
|
-
-
|
10
|
+
- gemfiles/activerecord_3.2.gemfile
|
11
|
+
- gemfiles/activerecord_4.0.gemfile
|
12
|
+
- gemfiles/activerecord_4.1.gemfile
|
13
|
+
- gemfiles/activerecord_4.2.gemfile
|
14
|
+
- gemfiles/activerecord_head.gemfile
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
18
|
+
- rvm: jruby-19mode
|
19
|
+
bundler_args: --without local_development
|
data/Appraisals
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
appraise 'activerecord-3.2' do
|
2
|
+
gem 'activerecord', '~> 3.2.0'
|
3
|
+
end
|
4
|
+
|
5
|
+
appraise 'activerecord-4.0' do
|
6
|
+
gem 'activerecord', '~> 4.0.0'
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise 'activerecord-4.1' do
|
10
|
+
gem 'activerecord', '~> 4.1.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise 'activerecord-4.2' do
|
14
|
+
gem 'activerecord', '~> 4.2.0'
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise 'activerecord-head' do
|
18
|
+
git 'git://github.com/rails/arel.git' do
|
19
|
+
gem 'arel'
|
20
|
+
end
|
21
|
+
git 'git://github.com/rails/rails.git' do
|
22
|
+
gem 'activerecord'
|
23
|
+
end
|
24
|
+
end
|
data/Gemfile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
source
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in power_dup.gemspec
|
1
|
+
source 'https://rubygems.org'
|
4
2
|
gemspec
|
5
|
-
gem 'activerecord', '~> 4.1.2'
|
6
3
|
|
7
4
|
group :development, :test do
|
8
5
|
gem 'rake'
|
9
6
|
gem 'coveralls', require: false
|
10
7
|
end
|
8
|
+
|
9
|
+
group :local_development do
|
10
|
+
gem 'pry'
|
11
|
+
gem 'appraisal'
|
12
|
+
end
|
data/README.md
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Amoeba
|
2
2
|
|
3
|
-
|
3
|
+
Easy cloning of active_record objects including associations and several operations under associations and attributes.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
Easy copying of rails associations such as `has_many`.
|
8
|
-
|
9
|
-
![amoebalogo](http://rocksolidwebdesign.com/wp_cms/wp-content/uploads/2012/02/amoeba_logo.jpg)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/rocksolidwebdesign/amoeba/badges/gpa.svg)](https://codeclimate.com/github/rocksolidwebdesign/amoeba)
|
10
6
|
|
11
7
|
## What?
|
12
8
|
|
@@ -18,7 +14,7 @@ This gem is named "Amoeba" because amoebas are (small life forms that are) good
|
|
18
14
|
|
19
15
|
An ActiveRecord extension gem to allow the duplication of associated child record objects when duplicating an active record model.
|
20
16
|
|
21
|
-
Rails 3.2 compatible.
|
17
|
+
Rails 3.2, 4.x compatible.
|
22
18
|
|
23
19
|
### Features
|
24
20
|
|
@@ -116,8 +112,8 @@ If you only want some of the associations copied but not others, you may use the
|
|
116
112
|
|
117
113
|
amoeba do
|
118
114
|
enable
|
119
|
-
|
120
|
-
|
115
|
+
include_association :tags
|
116
|
+
include_association :authors
|
121
117
|
end
|
122
118
|
end
|
123
119
|
|
@@ -133,8 +129,8 @@ Using the inclusive style within the amoeba block actually implies that you wish
|
|
133
129
|
has_many :authors
|
134
130
|
|
135
131
|
amoeba do
|
136
|
-
|
137
|
-
|
132
|
+
include_association :tags
|
133
|
+
include_association :authors
|
138
134
|
end
|
139
135
|
end
|
140
136
|
|
@@ -142,7 +138,7 @@ Using the inclusive style within the amoeba block actually implies that you wish
|
|
142
138
|
belongs_to :post
|
143
139
|
end
|
144
140
|
|
145
|
-
You may also specify fields to be copied by passing an array. If you call the `
|
141
|
+
You may also specify fields to be copied by passing an array. If you call the `include_association` with a single value, it will be appended to the list of already included fields. If you pass an array, your array will overwrite the original values.
|
146
142
|
|
147
143
|
class Post < ActiveRecord::Base
|
148
144
|
has_many :comments
|
@@ -150,7 +146,7 @@ You may also specify fields to be copied by passing an array. If you call the `i
|
|
150
146
|
has_many :authors
|
151
147
|
|
152
148
|
amoeba do
|
153
|
-
|
149
|
+
include_association [:tags, :authors]
|
154
150
|
end
|
155
151
|
end
|
156
152
|
|
@@ -172,7 +168,7 @@ If you have more fields to include than to exclude, you may wish to shorten the
|
|
172
168
|
has_many :authors
|
173
169
|
|
174
170
|
amoeba do
|
175
|
-
|
171
|
+
exclude_association :comments
|
176
172
|
end
|
177
173
|
end
|
178
174
|
|
@@ -182,7 +178,7 @@ If you have more fields to include than to exclude, you may wish to shorten the
|
|
182
178
|
|
183
179
|
This example does the same thing as the inclusive style example, it will copy the post's tags and authors but not its comments. As with inclusive style, there is no need to explicitly enable amoeba when specifying fields to exclude.
|
184
180
|
|
185
|
-
The exclusive style, when used, will automatically disable any other style that was previously selected, so if you selected include fields, and then you choose some exclude fields, the `
|
181
|
+
The exclusive style, when used, will automatically disable any other style that was previously selected, so if you selected include fields, and then you choose some exclude fields, the `exclude_association` method will disable the previously slected inclusive style and wipe out any corresponding include fields.
|
186
182
|
|
187
183
|
#### Cloning
|
188
184
|
|
@@ -218,7 +214,7 @@ This example will actually duplicate the warnings and widgets in the database. I
|
|
218
214
|
|
219
215
|
#### Limiting Association Types
|
220
216
|
|
221
|
-
By default, amoeba recognizes and
|
217
|
+
By default, amoeba recognizes and attempts to copy any children of the following association types:
|
222
218
|
|
223
219
|
- has one
|
224
220
|
- has many
|
@@ -346,7 +342,7 @@ or this, using an array:
|
|
346
342
|
has_and_belongs_to_many :tags
|
347
343
|
|
348
344
|
amoeba do
|
349
|
-
|
345
|
+
include_association :tags
|
350
346
|
|
351
347
|
customize([
|
352
348
|
lambda do |orig_obj,copy_of_obj|
|
@@ -413,11 +409,11 @@ This example should result in something like this:
|
|
413
409
|
new_post.title # "Copy of Hello world"
|
414
410
|
new_post.contents # "Original contents: I like cats, cats are awesome. (copied version)"
|
415
411
|
|
416
|
-
Like `nullify`, the preprocessing directives do not automatically enable the copying of associated child records. If only preprocessing directives are used and you do want to copy child records and no `
|
412
|
+
Like `nullify`, the preprocessing directives do not automatically enable the copying of associated child records. If only preprocessing directives are used and you do want to copy child records and no `include_association` or `exclude_association` list is provided, you must still explicitly enable the copying of child records by calling the enable method from within the amoeba block on your model.
|
417
413
|
|
418
414
|
### Precedence
|
419
415
|
|
420
|
-
You may use a combination of configuration methods within each model's amoeba block. Recognized association types take precedence over inclusion or exclusion lists. Inclusive style takes precedence over exclusive style, and these two explicit styles take precedence over the indiscriminate style. In other words, if you list fields to copy, amoeba will only copy the fields you list, or only copy the fields you don't exclude as the case may be. Additionally, if a field type is not recognized it will not be copied, regardless of whether it appears in an inclusion list. If you want amoeba to automatically copy all of your child records, do not list any fields using either `
|
416
|
+
You may use a combination of configuration methods within each model's amoeba block. Recognized association types take precedence over inclusion or exclusion lists. Inclusive style takes precedence over exclusive style, and these two explicit styles take precedence over the indiscriminate style. In other words, if you list fields to copy, amoeba will only copy the fields you list, or only copy the fields you don't exclude as the case may be. Additionally, if a field type is not recognized it will not be copied, regardless of whether it appears in an inclusion list. If you want amoeba to automatically copy all of your child records, do not list any fields using either `include_association` or `exclude_association`.
|
421
417
|
|
422
418
|
The following example syntax is perfectly valid, and will result in the usage of inclusive style. The order in which you call the configuration methods within the amoeba block does not matter:
|
423
419
|
|
@@ -432,13 +428,13 @@ The following example syntax is perfectly valid, and will result in the usage of
|
|
432
428
|
has_many :authors
|
433
429
|
|
434
430
|
amoeba do
|
435
|
-
|
436
|
-
|
431
|
+
exclude_association :authors
|
432
|
+
include_association :tags
|
437
433
|
nullify :date_published
|
438
434
|
prepend :title => "Copy of "
|
439
435
|
append :contents => " (copied version)"
|
440
436
|
regex :contents => {:replace => /dog/, :with => 'cat'}
|
441
|
-
|
437
|
+
include_association :authors
|
442
438
|
enable
|
443
439
|
nullify :topic_id
|
444
440
|
end
|
@@ -450,7 +446,7 @@ The following example syntax is perfectly valid, and will result in the usage of
|
|
450
446
|
|
451
447
|
This example will copy all of a post's tags and authors, but not its comments. It will also nullify the publishing date and dissociate the post from its original topic. It will also preprocess the post's fields as in the previous preprocessing example.
|
452
448
|
|
453
|
-
Note that, because of precedence, inclusive style is used and the list of exclude fields is never consulted. Additionally, the `enable` method is redundant because amoeba is automatically enabled when using `
|
449
|
+
Note that, because of precedence, inclusive style is used and the list of exclude fields is never consulted. Additionally, the `enable` method is redundant because amoeba is automatically enabled when using `include_association`.
|
454
450
|
|
455
451
|
The preprocessing directives are run after child records are copied andare run in this order.
|
456
452
|
|
@@ -646,18 +642,18 @@ The `:relaxed` parenting style will prefer parent settings.
|
|
646
642
|
has_and_belongs_to_many :sections
|
647
643
|
|
648
644
|
amoeba do
|
649
|
-
|
645
|
+
exclude_association :images
|
650
646
|
propagate :relaxed
|
651
647
|
end
|
652
648
|
end
|
653
649
|
|
654
650
|
class Shirt < Product
|
655
|
-
|
656
|
-
|
651
|
+
include_association :images
|
652
|
+
include_association :sections
|
657
653
|
prepend :title => "Copy of "
|
658
654
|
end
|
659
655
|
|
660
|
-
In this example, the conflicting `
|
656
|
+
In this example, the conflicting `include_association` settings on the child will be ignored and the parent `exclude_association` setting will be used, while the `prepend` setting on the child will be honored because it doesn't conflict with the parent.
|
661
657
|
|
662
658
|
##### Strict Parenting
|
663
659
|
|
@@ -668,18 +664,18 @@ The `:strict` style will ignore child settings altogether and inherit any parent
|
|
668
664
|
has_and_belongs_to_many :sections
|
669
665
|
|
670
666
|
amoeba do
|
671
|
-
|
667
|
+
exclude_association :images
|
672
668
|
propagate :strict
|
673
669
|
end
|
674
670
|
end
|
675
671
|
|
676
672
|
class Shirt < Product
|
677
|
-
|
678
|
-
|
673
|
+
include_association :images
|
674
|
+
include_association :sections
|
679
675
|
prepend :title => "Copy of "
|
680
676
|
end
|
681
677
|
|
682
|
-
In this example, the only processing that will happen when a Shirt is duplicated is whatever processing is allowed by the parent. So in this case the parent's `
|
678
|
+
In this example, the only processing that will happen when a Shirt is duplicated is whatever processing is allowed by the parent. So in this case the parent's `exclude_association` directive takes precedence over the child's `include_association` settings, and not only that, but none of the other settings for the child are used either. The `prepend` setting of the child is completely ignored.
|
683
679
|
|
684
680
|
##### Parenting and Precedence
|
685
681
|
|
@@ -704,13 +700,13 @@ This version will use both the parent and child settings, so both the images and
|
|
704
700
|
has_and_belongs_to_many :sections
|
705
701
|
|
706
702
|
amoeba do
|
707
|
-
|
703
|
+
include_association :images
|
708
704
|
propagate
|
709
705
|
end
|
710
706
|
end
|
711
707
|
|
712
708
|
class Shirt < Product
|
713
|
-
|
709
|
+
include_association :sections
|
714
710
|
end
|
715
711
|
|
716
712
|
The next version will use only the child settings because passing an array will override any previous settings rather than adding to them and the child config takes precedence in the `submissive` parenting style. So in this case only the sections will be copied.
|
@@ -720,13 +716,13 @@ The next version will use only the child settings because passing an array will
|
|
720
716
|
has_and_belongs_to_many :sections
|
721
717
|
|
722
718
|
amoeba do
|
723
|
-
|
719
|
+
include_association :images
|
724
720
|
propagate
|
725
721
|
end
|
726
722
|
end
|
727
723
|
|
728
724
|
class Shirt < Product
|
729
|
-
|
725
|
+
include_association [:sections]
|
730
726
|
end
|
731
727
|
|
732
728
|
##### A Relaxed Override Example
|
@@ -738,13 +734,13 @@ This version will use both the parent and child settings, so both the images and
|
|
738
734
|
has_and_belongs_to_many :sections
|
739
735
|
|
740
736
|
amoeba do
|
741
|
-
|
737
|
+
include_association :images
|
742
738
|
propagate :relaxed
|
743
739
|
end
|
744
740
|
end
|
745
741
|
|
746
742
|
class Shirt < Product
|
747
|
-
|
743
|
+
include_association :sections
|
748
744
|
end
|
749
745
|
|
750
746
|
The next version will use only the parent settings because passing an array will override any previous settings rather than adding to them and the parent config takes precedence in the `relaxed` parenting style. So in this case only the images will be copied.
|
@@ -754,13 +750,13 @@ The next version will use only the parent settings because passing an array will
|
|
754
750
|
has_and_belongs_to_many :sections
|
755
751
|
|
756
752
|
amoeba do
|
757
|
-
|
753
|
+
include_association [:images]
|
758
754
|
propagate
|
759
755
|
end
|
760
756
|
end
|
761
757
|
|
762
758
|
class Shirt < Product
|
763
|
-
|
759
|
+
include_association :sections
|
764
760
|
end
|
765
761
|
|
766
762
|
### Validating Nested Attributes
|
@@ -791,7 +787,7 @@ For example this will throw a validation error saying that your posts are invali
|
|
791
787
|
|
792
788
|
author.save # this will fail validation
|
793
789
|
|
794
|
-
|
790
|
+
Where this will work fine:
|
795
791
|
|
796
792
|
class Author < ActiveRecord::Base
|
797
793
|
has_many :posts, :inverse_of => :author
|
@@ -847,21 +843,102 @@ This issue with `accepts_nested_attributes_for` can also be solved by using `:in
|
|
847
843
|
|
848
844
|
The crux of the issue is that upon duplication, the new `Author` instance does not yet have an ID because it has not yet been persisted, so the `:posts` do not yet have an `:author_id` either, and thus no `:author` and thus they will fail validation. This issue may likely affect amoeba usage so if you get some validation failures, be sure to add `:inverse_of` to your models.
|
849
845
|
|
846
|
+
|
847
|
+
## Cloning using custom method
|
848
|
+
|
849
|
+
If you need to clone model with custom method you can use `through`:
|
850
|
+
|
851
|
+
class ChildPrototype < ActiveRecord::Base
|
852
|
+
amoeba do
|
853
|
+
through :become_child
|
854
|
+
end
|
855
|
+
|
856
|
+
def become_child
|
857
|
+
self.dup.becomes(Child)
|
858
|
+
end
|
859
|
+
end
|
860
|
+
|
861
|
+
class Child < ChildPrototype
|
862
|
+
end
|
863
|
+
|
864
|
+
After cloning we will get instance of `Child` instead of `ChildPrototype`
|
865
|
+
|
866
|
+
## Remapping associations
|
867
|
+
|
868
|
+
If you will need to do complex cloning with remapping associations name you can user `remapper`:
|
869
|
+
|
870
|
+
class ObjectPrototype < ActiveRecord::Base
|
871
|
+
has_many :child_prototypes
|
872
|
+
|
873
|
+
amoeba do
|
874
|
+
method :become_real
|
875
|
+
remapper :remap_associations
|
876
|
+
end
|
877
|
+
|
878
|
+
def become_real
|
879
|
+
self.dup().becomes( RealObject )
|
880
|
+
end
|
881
|
+
|
882
|
+
def remap_associations( name )
|
883
|
+
:childs if name == :child_prototypes
|
884
|
+
end
|
885
|
+
end
|
886
|
+
|
887
|
+
class RealObject < ObjectPrototype
|
888
|
+
has_many :childs
|
889
|
+
end
|
890
|
+
|
891
|
+
class ChildPrototype < ActiveRecord::Base
|
892
|
+
amoeba do
|
893
|
+
method :become_child
|
894
|
+
end
|
895
|
+
|
896
|
+
def become_child
|
897
|
+
self.dup().becomes( Child )
|
898
|
+
end
|
899
|
+
end
|
900
|
+
|
901
|
+
class Child < ChildPrototype
|
902
|
+
end
|
903
|
+
|
904
|
+
In result we will get next:
|
905
|
+
|
906
|
+
prototype = ObjectPrototype.new
|
907
|
+
prototype.child_prototypes << ChildPrototype.new
|
908
|
+
object = prototype.amoeba_dup
|
909
|
+
object.class # => RealObject
|
910
|
+
object.childs.first.class #=> Child
|
911
|
+
|
850
912
|
## Configuration Reference
|
851
913
|
|
852
914
|
Here is a static reference to the available configuration methods, usable within the amoeba block on your rails models.
|
853
915
|
|
916
|
+
### through
|
917
|
+
|
918
|
+
Set method what we will use for cloning model instead of `dup`.
|
919
|
+
|
920
|
+
for example:
|
921
|
+
|
922
|
+
amoeba do
|
923
|
+
through :supper_pupper_dup
|
924
|
+
end
|
925
|
+
|
926
|
+
def supper_pupper_dup
|
927
|
+
puts "multiplied by budding"
|
928
|
+
self.dup
|
929
|
+
end
|
930
|
+
|
854
931
|
### Controlling Associations
|
855
932
|
|
856
933
|
#### enable
|
857
934
|
|
858
|
-
Enables amoeba in the default style of copying all known associated child records. Using the enable method is only required if you wish to enable amoeba but you are not using either the `
|
935
|
+
Enables amoeba in the default style of copying all known associated child records. Using the enable method is only required if you wish to enable amoeba but you are not using either the `include_association` or `exclude_association` directives. If you use either inclusive or exclusive style, amoeba is automatically enabled for you, so calling `enable` would be redundant, though it won't hurt.
|
859
936
|
|
860
|
-
####
|
937
|
+
#### include_association
|
861
938
|
|
862
939
|
Adds a field to the list of fields which should be copied. All associations not in this list will not be copied. This method may be called multiple times, once per desired field, or you may pass an array of field names. Passing a single symbol will add to the list of included fields. Passing an array will empty the list and replace it with the array you pass.
|
863
940
|
|
864
|
-
####
|
941
|
+
#### exclude_association
|
865
942
|
|
866
943
|
Adds a field to the list of fields which should not be copied. Only the associations that are not in this list will be copied. This method may be called multiple times, once per desired field, or you may pass an array of field names. Passing a single symbol will add to the list of excluded fields. Passing an array will empty the list and replace it with the array you pass.
|
867
944
|
|
@@ -897,6 +974,19 @@ Here is a static reference to the available configuration methods, usable within
|
|
897
974
|
|
898
975
|
will choose the relaxed parenting style of inherited settings for this child. A parenting style set via the `raised` method takes precedence over the parenting style set using the `propagate` method.
|
899
976
|
|
977
|
+
#### remapper
|
978
|
+
|
979
|
+
Set the method what will be used for remapping of association name. Method will have one argument - association name as Symbol. If method will return nil then association will not be remapped.
|
980
|
+
|
981
|
+
for example:
|
982
|
+
amoeba do
|
983
|
+
remapper :childs_to_parents
|
984
|
+
end
|
985
|
+
|
986
|
+
def childs_to_parents(association_name)
|
987
|
+
:parents if association_name == :childs
|
988
|
+
end
|
989
|
+
|
900
990
|
### Pre-Processing Fields
|
901
991
|
|
902
992
|
#### nullify
|