mongoid_paranoia 0.2.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/LICENSE +21 -21
- data/README.md +117 -124
- data/lib/mongoid-paranoia.rb +3 -1
- data/lib/mongoid/paranoia.rb +206 -208
- data/lib/mongoid/paranoia/configuration.rb +13 -11
- data/lib/mongoid/paranoia/monkey_patches.rb +114 -113
- data/lib/mongoid/paranoia/version.rb +7 -5
- data/lib/mongoid_paranoia.rb +3 -1
- data/perf/scope.rb +65 -64
- data/spec/app/models/address.rb +71 -71
- data/spec/app/models/appointment.rb +7 -7
- data/spec/app/models/author.rb +6 -6
- data/spec/app/models/fish.rb +8 -8
- data/spec/app/models/paranoid_phone.rb +25 -25
- data/spec/app/models/paranoid_post.rb +65 -65
- data/spec/app/models/person.rb +21 -21
- data/spec/app/models/phone.rb +11 -11
- data/spec/app/models/relations.rb +247 -247
- data/spec/app/models/tag.rb +6 -6
- data/spec/app/models/title.rb +4 -4
- data/spec/mongoid/configuration_spec.rb +19 -19
- data/spec/mongoid/document_spec.rb +21 -21
- data/spec/mongoid/nested_attributes_spec.rb +164 -164
- data/spec/mongoid/paranoia_spec.rb +887 -887
- data/spec/mongoid/scoping_spec.rb +55 -55
- data/spec/mongoid/validatable/uniqueness_spec.rb +74 -74
- data/spec/spec_helper.rb +43 -73
- metadata +30 -27
@@ -1,7 +1,7 @@
|
|
1
|
-
class Appointment
|
2
|
-
include Mongoid::Document
|
3
|
-
field :active, type: Boolean, default: true
|
4
|
-
field :timed, type: Boolean, default: true
|
5
|
-
embedded_in :person
|
6
|
-
default_scope ->{where(active: true)}
|
7
|
-
end
|
1
|
+
class Appointment
|
2
|
+
include Mongoid::Document
|
3
|
+
field :active, type: Boolean, default: true
|
4
|
+
field :timed, type: Boolean, default: true
|
5
|
+
embedded_in :person
|
6
|
+
default_scope ->{where(active: true)}
|
7
|
+
end
|
data/spec/app/models/author.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
class Author
|
2
|
-
include Mongoid::Document
|
3
|
-
field :name, type: String
|
4
|
-
|
5
|
-
belongs_to :post, class_name: "ParanoidPost"
|
6
|
-
end
|
1
|
+
class Author
|
2
|
+
include Mongoid::Document
|
3
|
+
field :name, type: String
|
4
|
+
|
5
|
+
belongs_to :post, class_name: "ParanoidPost"
|
6
|
+
end
|
data/spec/app/models/fish.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
class Fish
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Paranoia
|
4
|
-
|
5
|
-
def self.fresh
|
6
|
-
where(fresh: true)
|
7
|
-
end
|
8
|
-
end
|
1
|
+
class Fish
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Paranoia
|
4
|
+
|
5
|
+
def self.fresh
|
6
|
+
where(fresh: true)
|
7
|
+
end
|
8
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
class ParanoidPhone
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Paranoia
|
4
|
-
|
5
|
-
attr_accessor :after_destroy_called, :before_destroy_called
|
6
|
-
|
7
|
-
field :number, type: String
|
8
|
-
|
9
|
-
embedded_in :person
|
10
|
-
|
11
|
-
before_destroy :before_destroy_stub, :halt_me
|
12
|
-
after_destroy :after_destroy_stub
|
13
|
-
|
14
|
-
def before_destroy_stub
|
15
|
-
self.before_destroy_called = true
|
16
|
-
end
|
17
|
-
|
18
|
-
def after_destroy_stub
|
19
|
-
self.after_destroy_called = true
|
20
|
-
end
|
21
|
-
|
22
|
-
def halt_me
|
23
|
-
person.age == 42
|
24
|
-
end
|
25
|
-
end
|
1
|
+
class ParanoidPhone
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Paranoia
|
4
|
+
|
5
|
+
attr_accessor :after_destroy_called, :before_destroy_called
|
6
|
+
|
7
|
+
field :number, type: String
|
8
|
+
|
9
|
+
embedded_in :person
|
10
|
+
|
11
|
+
before_destroy :before_destroy_stub, :halt_me
|
12
|
+
after_destroy :after_destroy_stub
|
13
|
+
|
14
|
+
def before_destroy_stub
|
15
|
+
self.before_destroy_called = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def after_destroy_stub
|
19
|
+
self.after_destroy_called = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def halt_me
|
23
|
+
throw :abort if person.age == 42
|
24
|
+
end
|
25
|
+
end
|
@@ -1,65 +1,65 @@
|
|
1
|
-
class ParanoidPost
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Paranoia
|
4
|
-
|
5
|
-
field :title, type: String
|
6
|
-
|
7
|
-
attr_accessor :after_destroy_called, :before_destroy_called,
|
8
|
-
:after_restore_called, :before_restore_called,
|
9
|
-
:after_remove_called, :before_remove_called,
|
10
|
-
:around_before_restore_called, :around_after_restore_called
|
11
|
-
|
12
|
-
belongs_to :person
|
13
|
-
|
14
|
-
has_and_belongs_to_many :tags
|
15
|
-
has_many :authors, dependent: :
|
16
|
-
has_many :titles, dependent: :
|
17
|
-
|
18
|
-
scope :recent, -> {where(created_at: { "$lt" => Time.now, "$gt" => 30.days.ago })}
|
19
|
-
|
20
|
-
before_destroy :before_destroy_stub
|
21
|
-
after_destroy :after_destroy_stub
|
22
|
-
|
23
|
-
before_remove :before_remove_stub
|
24
|
-
after_remove :after_remove_stub
|
25
|
-
|
26
|
-
before_restore :before_restore_stub
|
27
|
-
after_restore :after_restore_stub
|
28
|
-
around_restore :around_restore_stub
|
29
|
-
|
30
|
-
def before_destroy_stub
|
31
|
-
self.before_destroy_called = true
|
32
|
-
end
|
33
|
-
|
34
|
-
def after_destroy_stub
|
35
|
-
self.after_destroy_called = true
|
36
|
-
end
|
37
|
-
|
38
|
-
def before_remove_stub
|
39
|
-
self.before_remove_called = true
|
40
|
-
end
|
41
|
-
|
42
|
-
def after_remove_stub
|
43
|
-
self.after_remove_called = true
|
44
|
-
end
|
45
|
-
|
46
|
-
def before_restore_stub
|
47
|
-
self.before_restore_called = true
|
48
|
-
end
|
49
|
-
|
50
|
-
def after_restore_stub
|
51
|
-
self.after_restore_called = true
|
52
|
-
end
|
53
|
-
|
54
|
-
def around_restore_stub
|
55
|
-
self.around_before_restore_called = true
|
56
|
-
yield
|
57
|
-
self.around_after_restore_called = true
|
58
|
-
end
|
59
|
-
|
60
|
-
class << self
|
61
|
-
def old
|
62
|
-
where(created_at: { "$lt" => 30.days.ago })
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
1
|
+
class ParanoidPost
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Paranoia
|
4
|
+
|
5
|
+
field :title, type: String
|
6
|
+
|
7
|
+
attr_accessor :after_destroy_called, :before_destroy_called,
|
8
|
+
:after_restore_called, :before_restore_called,
|
9
|
+
:after_remove_called, :before_remove_called,
|
10
|
+
:around_before_restore_called, :around_after_restore_called
|
11
|
+
|
12
|
+
belongs_to :person
|
13
|
+
|
14
|
+
has_and_belongs_to_many :tags
|
15
|
+
has_many :authors, dependent: :delete_all, inverse_of: :post
|
16
|
+
has_many :titles, dependent: :restrict_with_error
|
17
|
+
|
18
|
+
scope :recent, -> {where(created_at: { "$lt" => Time.now, "$gt" => 30.days.ago })}
|
19
|
+
|
20
|
+
before_destroy :before_destroy_stub
|
21
|
+
after_destroy :after_destroy_stub
|
22
|
+
|
23
|
+
before_remove :before_remove_stub
|
24
|
+
after_remove :after_remove_stub
|
25
|
+
|
26
|
+
before_restore :before_restore_stub
|
27
|
+
after_restore :after_restore_stub
|
28
|
+
around_restore :around_restore_stub
|
29
|
+
|
30
|
+
def before_destroy_stub
|
31
|
+
self.before_destroy_called = true
|
32
|
+
end
|
33
|
+
|
34
|
+
def after_destroy_stub
|
35
|
+
self.after_destroy_called = true
|
36
|
+
end
|
37
|
+
|
38
|
+
def before_remove_stub
|
39
|
+
self.before_remove_called = true
|
40
|
+
end
|
41
|
+
|
42
|
+
def after_remove_stub
|
43
|
+
self.after_remove_called = true
|
44
|
+
end
|
45
|
+
|
46
|
+
def before_restore_stub
|
47
|
+
self.before_restore_called = true
|
48
|
+
end
|
49
|
+
|
50
|
+
def after_restore_stub
|
51
|
+
self.after_restore_called = true
|
52
|
+
end
|
53
|
+
|
54
|
+
def around_restore_stub
|
55
|
+
self.around_before_restore_called = true
|
56
|
+
yield
|
57
|
+
self.around_after_restore_called = true
|
58
|
+
end
|
59
|
+
|
60
|
+
class << self
|
61
|
+
def old
|
62
|
+
where(created_at: { "$lt" => 30.days.ago })
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/spec/app/models/person.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
class Person
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
field :age, type: Integer, default: "100"
|
5
|
-
field :score, type: Integer
|
6
|
-
|
7
|
-
attr_reader :rescored
|
8
|
-
|
9
|
-
embeds_many :phone_numbers, class_name: "Phone", validate: false
|
10
|
-
embeds_many :phones, store_as: :mobile_phones, validate: false
|
11
|
-
embeds_many :addresses, as: :addressable, validate: false
|
12
|
-
|
13
|
-
embeds_many :appointments, validate: false
|
14
|
-
embeds_many :paranoid_phones, validate: false
|
15
|
-
|
16
|
-
has_many :paranoid_posts, validate: false
|
17
|
-
belongs_to :paranoid_post
|
18
|
-
|
19
|
-
accepts_nested_attributes_for :addresses
|
20
|
-
accepts_nested_attributes_for :paranoid_phones
|
21
|
-
end
|
1
|
+
class Person
|
2
|
+
include Mongoid::Document
|
3
|
+
|
4
|
+
field :age, type: Integer, default: "100"
|
5
|
+
field :score, type: Integer
|
6
|
+
|
7
|
+
attr_reader :rescored
|
8
|
+
|
9
|
+
embeds_many :phone_numbers, class_name: "Phone", validate: false
|
10
|
+
embeds_many :phones, store_as: :mobile_phones, validate: false
|
11
|
+
embeds_many :addresses, as: :addressable, validate: false
|
12
|
+
|
13
|
+
embeds_many :appointments, validate: false
|
14
|
+
embeds_many :paranoid_phones, validate: false
|
15
|
+
|
16
|
+
has_many :paranoid_posts, validate: false
|
17
|
+
belongs_to :paranoid_post
|
18
|
+
|
19
|
+
accepts_nested_attributes_for :addresses
|
20
|
+
accepts_nested_attributes_for :paranoid_phones
|
21
|
+
end
|
data/spec/app/models/phone.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
class Phone
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
attr_accessor :number_in_observer
|
5
|
-
|
6
|
-
field :_id, type: String, default: ->{ number }
|
7
|
-
|
8
|
-
field :number
|
9
|
-
embeds_one :country_code
|
10
|
-
embedded_in :person
|
11
|
-
end
|
1
|
+
class Phone
|
2
|
+
include Mongoid::Document
|
3
|
+
|
4
|
+
attr_accessor :number_in_observer
|
5
|
+
|
6
|
+
field :_id, type: String, default: ->{ number }
|
7
|
+
|
8
|
+
field :number
|
9
|
+
embeds_one :country_code
|
10
|
+
embedded_in :person
|
11
|
+
end
|
@@ -1,247 +1,247 @@
|
|
1
|
-
class NormBase
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
has_one :norm_has_one, dependent: :destroy
|
5
|
-
has_one :para_has_one, dependent: :destroy
|
6
|
-
|
7
|
-
has_many :norm_has_many, dependent: :destroy
|
8
|
-
has_many :para_has_many, dependent: :destroy
|
9
|
-
|
10
|
-
has_many :norm_has_many_poly, dependent: :destroy
|
11
|
-
has_many :para_has_many_poly, dependent: :destroy
|
12
|
-
|
13
|
-
belongs_to :norm_belongs_to_one, dependent: :destroy
|
14
|
-
belongs_to :para_belongs_to_one, dependent: :destroy
|
15
|
-
|
16
|
-
belongs_to :norm_belongs_to, dependent: :destroy
|
17
|
-
belongs_to :para_belongs_to, dependent: :destroy
|
18
|
-
|
19
|
-
has_and_belongs_to_many :norm_habtm, dependent: :destroy
|
20
|
-
has_and_belongs_to_many :para_habtm, dependent: :destroy
|
21
|
-
|
22
|
-
embeds_one :norm_embeds_one
|
23
|
-
embeds_one :para_embeds_one
|
24
|
-
|
25
|
-
embeds_many :norm_embeds_many
|
26
|
-
embeds_many :para_embeds_many
|
27
|
-
|
28
|
-
embeds_many :norm_embeds_many_poly
|
29
|
-
embeds_many :para_embeds_many_poly
|
30
|
-
end
|
31
|
-
|
32
|
-
class ParaBase
|
33
|
-
include Mongoid::Document
|
34
|
-
include Mongoid::Paranoia
|
35
|
-
|
36
|
-
has_one :norm_has_one, dependent: :destroy
|
37
|
-
has_one :para_has_one, dependent: :destroy
|
38
|
-
|
39
|
-
has_many :norm_has_many, dependent: :destroy
|
40
|
-
has_many :para_has_many, dependent: :destroy
|
41
|
-
|
42
|
-
has_many :norm_has_many_poly, dependent: :destroy
|
43
|
-
has_many :para_has_many_poly, dependent: :destroy
|
44
|
-
|
45
|
-
belongs_to :norm_belongs_to_one, dependent: :destroy
|
46
|
-
belongs_to :para_belongs_to_one, dependent: :destroy
|
47
|
-
|
48
|
-
belongs_to :norm_belongs_to, dependent: :destroy
|
49
|
-
belongs_to :para_belongs_to, dependent: :destroy
|
50
|
-
|
51
|
-
has_and_belongs_to_many :norm_habtm, dependent: :destroy
|
52
|
-
has_and_belongs_to_many :para_habtm, dependent: :destroy
|
53
|
-
|
54
|
-
embeds_one :norm_embeds_one
|
55
|
-
embeds_one :para_embeds_one
|
56
|
-
|
57
|
-
embeds_many :norm_embeds_many
|
58
|
-
embeds_many :para_embeds_many
|
59
|
-
|
60
|
-
embeds_many :norm_embeds_many_poly
|
61
|
-
embeds_many :para_embeds_many_poly
|
62
|
-
end
|
63
|
-
|
64
|
-
class NormHasOne
|
65
|
-
include Mongoid::Document
|
66
|
-
|
67
|
-
belongs_to :norm_base
|
68
|
-
belongs_to :para_base
|
69
|
-
|
70
|
-
has_one :norm_belongs_to, dependent: :destroy
|
71
|
-
has_one :para_belongs_to, dependent: :destroy
|
72
|
-
|
73
|
-
has_one :norm_habtm, dependent: :destroy
|
74
|
-
has_one :norm_habtm, dependent: :destroy
|
75
|
-
end
|
76
|
-
|
77
|
-
class NormHasMany
|
78
|
-
include Mongoid::Document
|
79
|
-
|
80
|
-
belongs_to :norm_base
|
81
|
-
belongs_to :para_base
|
82
|
-
|
83
|
-
has_many :norm_belongs_to, dependent: :destroy
|
84
|
-
has_many :para_belongs_to, dependent: :destroy
|
85
|
-
|
86
|
-
has_many :norm_habtm, dependent: :destroy
|
87
|
-
has_many :norm_habtm, dependent: :destroy
|
88
|
-
end
|
89
|
-
|
90
|
-
class NormHasManyPoly
|
91
|
-
include Mongoid::Document
|
92
|
-
|
93
|
-
belongs_to :base, polymorphic: true
|
94
|
-
end
|
95
|
-
|
96
|
-
class NormBelongsToOne
|
97
|
-
include Mongoid::Document
|
98
|
-
|
99
|
-
has_one :norm_base
|
100
|
-
has_one :para_base
|
101
|
-
end
|
102
|
-
|
103
|
-
class NormBelongsTo
|
104
|
-
include Mongoid::Document
|
105
|
-
|
106
|
-
has_many :norm_base
|
107
|
-
has_many :para_base
|
108
|
-
|
109
|
-
belongs_to :norm_has_one, dependent: :destroy
|
110
|
-
belongs_to :para_has_one, dependent: :destroy
|
111
|
-
|
112
|
-
belongs_to :norm_has_many, dependent: :destroy
|
113
|
-
belongs_to :para_has_many, dependent: :destroy
|
114
|
-
end
|
115
|
-
|
116
|
-
class NormHabtm
|
117
|
-
include Mongoid::Document
|
118
|
-
|
119
|
-
has_and_belongs_to_many :norm_base
|
120
|
-
has_and_belongs_to_many :para_base
|
121
|
-
|
122
|
-
belongs_to :norm_has_one, dependent: :destroy
|
123
|
-
belongs_to :para_has_one, dependent: :destroy
|
124
|
-
|
125
|
-
belongs_to :norm_has_many, dependent: :destroy
|
126
|
-
belongs_to :para_has_many, dependent: :destroy
|
127
|
-
|
128
|
-
has_and_belongs_to_many :recursive, class_name: 'NormHabtm', inverse_of: :recursive, dependent: :destroy
|
129
|
-
has_and_belongs_to_many :para_habtm, dependent: :destroy
|
130
|
-
end
|
131
|
-
|
132
|
-
class NormEmbedsOne
|
133
|
-
include Mongoid::Document
|
134
|
-
|
135
|
-
embedded_in :norm_base
|
136
|
-
embedded_in :para_base
|
137
|
-
end
|
138
|
-
|
139
|
-
class NormEmbedsMany
|
140
|
-
include Mongoid::Document
|
141
|
-
|
142
|
-
embedded_in :norm_base
|
143
|
-
embedded_in :para_base
|
144
|
-
end
|
145
|
-
|
146
|
-
class NormEmbedsManyPoly
|
147
|
-
include Mongoid::Document
|
148
|
-
|
149
|
-
embedded_in :base, polymorphic: true
|
150
|
-
end
|
151
|
-
|
152
|
-
class ParaHasOne
|
153
|
-
include Mongoid::Document
|
154
|
-
include Mongoid::Paranoia
|
155
|
-
|
156
|
-
belongs_to :norm_base
|
157
|
-
belongs_to :para_base
|
158
|
-
|
159
|
-
has_one :norm_belongs_to, dependent: :destroy
|
160
|
-
has_one :para_belongs_to, dependent: :destroy
|
161
|
-
|
162
|
-
has_one :norm_habtm, dependent: :destroy
|
163
|
-
has_one :norm_habtm, dependent: :destroy
|
164
|
-
end
|
165
|
-
|
166
|
-
class ParaHasMany
|
167
|
-
include Mongoid::Document
|
168
|
-
include Mongoid::Paranoia
|
169
|
-
|
170
|
-
belongs_to :norm_base
|
171
|
-
belongs_to :para_base
|
172
|
-
|
173
|
-
has_many :norm_belongs_to, dependent: :destroy
|
174
|
-
has_many :para_belongs_to, dependent: :destroy
|
175
|
-
|
176
|
-
has_many :norm_habtm, dependent: :destroy
|
177
|
-
has_many :norm_habtm, dependent: :destroy
|
178
|
-
end
|
179
|
-
|
180
|
-
class ParaHasManyPoly
|
181
|
-
include Mongoid::Document
|
182
|
-
include Mongoid::Paranoia
|
183
|
-
|
184
|
-
belongs_to :base, polymorphic: true
|
185
|
-
end
|
186
|
-
|
187
|
-
class ParaBelongsToOne
|
188
|
-
include Mongoid::Document
|
189
|
-
include Mongoid::Paranoia
|
190
|
-
|
191
|
-
has_one :norm_base
|
192
|
-
has_one :para_base
|
193
|
-
end
|
194
|
-
|
195
|
-
class ParaBelongsTo
|
196
|
-
include Mongoid::Document
|
197
|
-
include Mongoid::Paranoia
|
198
|
-
|
199
|
-
has_many :norm_base
|
200
|
-
has_many :para_base
|
201
|
-
|
202
|
-
belongs_to :norm_has_one, dependent: :destroy
|
203
|
-
belongs_to :para_has_one, dependent: :destroy
|
204
|
-
|
205
|
-
belongs_to :norm_has_many, dependent: :destroy
|
206
|
-
belongs_to :para_has_many, dependent: :destroy
|
207
|
-
end
|
208
|
-
|
209
|
-
class ParaHabtm
|
210
|
-
include Mongoid::Document
|
211
|
-
include Mongoid::Paranoia
|
212
|
-
|
213
|
-
has_and_belongs_to_many :norm_base
|
214
|
-
has_and_belongs_to_many :para_base
|
215
|
-
|
216
|
-
belongs_to :norm_has_one, dependent: :destroy
|
217
|
-
belongs_to :para_has_one, dependent: :destroy
|
218
|
-
|
219
|
-
belongs_to :norm_has_many, dependent: :destroy
|
220
|
-
belongs_to :para_has_many, dependent: :destroy
|
221
|
-
|
222
|
-
has_and_belongs_to_many :norm_habtm, dependent: :destroy
|
223
|
-
has_and_belongs_to_many :recursive, class_name: 'ParaHabtm', inverse_of: :recursive, dependent: :destroy
|
224
|
-
end
|
225
|
-
|
226
|
-
class ParaEmbedsOne
|
227
|
-
include Mongoid::Document
|
228
|
-
include Mongoid::Paranoia
|
229
|
-
|
230
|
-
embedded_in :norm_base
|
231
|
-
embedded_in :para_base
|
232
|
-
end
|
233
|
-
|
234
|
-
class ParaEmbedsMany
|
235
|
-
include Mongoid::Document
|
236
|
-
include Mongoid::Paranoia
|
237
|
-
|
238
|
-
embedded_in :norm_base
|
239
|
-
embedded_in :para_base
|
240
|
-
end
|
241
|
-
|
242
|
-
class ParaEmbedsManyPoly
|
243
|
-
include Mongoid::Document
|
244
|
-
include Mongoid::Paranoia
|
245
|
-
|
246
|
-
embedded_in :base, polymorphic: true
|
247
|
-
end
|
1
|
+
class NormBase
|
2
|
+
include Mongoid::Document
|
3
|
+
|
4
|
+
has_one :norm_has_one, dependent: :destroy
|
5
|
+
has_one :para_has_one, dependent: :destroy
|
6
|
+
|
7
|
+
has_many :norm_has_many, dependent: :destroy
|
8
|
+
has_many :para_has_many, dependent: :destroy
|
9
|
+
|
10
|
+
has_many :norm_has_many_poly, dependent: :destroy
|
11
|
+
has_many :para_has_many_poly, dependent: :destroy
|
12
|
+
|
13
|
+
belongs_to :norm_belongs_to_one, dependent: :destroy
|
14
|
+
belongs_to :para_belongs_to_one, dependent: :destroy
|
15
|
+
|
16
|
+
belongs_to :norm_belongs_to, dependent: :destroy
|
17
|
+
belongs_to :para_belongs_to, dependent: :destroy
|
18
|
+
|
19
|
+
has_and_belongs_to_many :norm_habtm, dependent: :destroy
|
20
|
+
has_and_belongs_to_many :para_habtm, dependent: :destroy
|
21
|
+
|
22
|
+
embeds_one :norm_embeds_one
|
23
|
+
embeds_one :para_embeds_one
|
24
|
+
|
25
|
+
embeds_many :norm_embeds_many
|
26
|
+
embeds_many :para_embeds_many
|
27
|
+
|
28
|
+
embeds_many :norm_embeds_many_poly
|
29
|
+
embeds_many :para_embeds_many_poly
|
30
|
+
end
|
31
|
+
|
32
|
+
class ParaBase
|
33
|
+
include Mongoid::Document
|
34
|
+
include Mongoid::Paranoia
|
35
|
+
|
36
|
+
has_one :norm_has_one, dependent: :destroy
|
37
|
+
has_one :para_has_one, dependent: :destroy
|
38
|
+
|
39
|
+
has_many :norm_has_many, dependent: :destroy
|
40
|
+
has_many :para_has_many, dependent: :destroy
|
41
|
+
|
42
|
+
has_many :norm_has_many_poly, dependent: :destroy
|
43
|
+
has_many :para_has_many_poly, dependent: :destroy
|
44
|
+
|
45
|
+
belongs_to :norm_belongs_to_one, dependent: :destroy
|
46
|
+
belongs_to :para_belongs_to_one, dependent: :destroy
|
47
|
+
|
48
|
+
belongs_to :norm_belongs_to, dependent: :destroy
|
49
|
+
belongs_to :para_belongs_to, dependent: :destroy
|
50
|
+
|
51
|
+
has_and_belongs_to_many :norm_habtm, dependent: :destroy
|
52
|
+
has_and_belongs_to_many :para_habtm, dependent: :destroy
|
53
|
+
|
54
|
+
embeds_one :norm_embeds_one
|
55
|
+
embeds_one :para_embeds_one
|
56
|
+
|
57
|
+
embeds_many :norm_embeds_many
|
58
|
+
embeds_many :para_embeds_many
|
59
|
+
|
60
|
+
embeds_many :norm_embeds_many_poly
|
61
|
+
embeds_many :para_embeds_many_poly
|
62
|
+
end
|
63
|
+
|
64
|
+
class NormHasOne
|
65
|
+
include Mongoid::Document
|
66
|
+
|
67
|
+
belongs_to :norm_base
|
68
|
+
belongs_to :para_base
|
69
|
+
|
70
|
+
has_one :norm_belongs_to, dependent: :destroy
|
71
|
+
has_one :para_belongs_to, dependent: :destroy
|
72
|
+
|
73
|
+
has_one :norm_habtm, dependent: :destroy
|
74
|
+
has_one :norm_habtm, dependent: :destroy
|
75
|
+
end
|
76
|
+
|
77
|
+
class NormHasMany
|
78
|
+
include Mongoid::Document
|
79
|
+
|
80
|
+
belongs_to :norm_base
|
81
|
+
belongs_to :para_base
|
82
|
+
|
83
|
+
has_many :norm_belongs_to, dependent: :destroy
|
84
|
+
has_many :para_belongs_to, dependent: :destroy
|
85
|
+
|
86
|
+
has_many :norm_habtm, dependent: :destroy
|
87
|
+
has_many :norm_habtm, dependent: :destroy
|
88
|
+
end
|
89
|
+
|
90
|
+
class NormHasManyPoly
|
91
|
+
include Mongoid::Document
|
92
|
+
|
93
|
+
belongs_to :base, polymorphic: true
|
94
|
+
end
|
95
|
+
|
96
|
+
class NormBelongsToOne
|
97
|
+
include Mongoid::Document
|
98
|
+
|
99
|
+
has_one :norm_base
|
100
|
+
has_one :para_base
|
101
|
+
end
|
102
|
+
|
103
|
+
class NormBelongsTo
|
104
|
+
include Mongoid::Document
|
105
|
+
|
106
|
+
has_many :norm_base
|
107
|
+
has_many :para_base
|
108
|
+
|
109
|
+
belongs_to :norm_has_one, dependent: :destroy
|
110
|
+
belongs_to :para_has_one, dependent: :destroy
|
111
|
+
|
112
|
+
belongs_to :norm_has_many, dependent: :destroy
|
113
|
+
belongs_to :para_has_many, dependent: :destroy
|
114
|
+
end
|
115
|
+
|
116
|
+
class NormHabtm
|
117
|
+
include Mongoid::Document
|
118
|
+
|
119
|
+
has_and_belongs_to_many :norm_base
|
120
|
+
has_and_belongs_to_many :para_base
|
121
|
+
|
122
|
+
belongs_to :norm_has_one, dependent: :destroy
|
123
|
+
belongs_to :para_has_one, dependent: :destroy
|
124
|
+
|
125
|
+
belongs_to :norm_has_many, dependent: :destroy
|
126
|
+
belongs_to :para_has_many, dependent: :destroy
|
127
|
+
|
128
|
+
has_and_belongs_to_many :recursive, class_name: 'NormHabtm', inverse_of: :recursive, dependent: :destroy
|
129
|
+
has_and_belongs_to_many :para_habtm, dependent: :destroy
|
130
|
+
end
|
131
|
+
|
132
|
+
class NormEmbedsOne
|
133
|
+
include Mongoid::Document
|
134
|
+
|
135
|
+
embedded_in :norm_base
|
136
|
+
embedded_in :para_base
|
137
|
+
end
|
138
|
+
|
139
|
+
class NormEmbedsMany
|
140
|
+
include Mongoid::Document
|
141
|
+
|
142
|
+
embedded_in :norm_base
|
143
|
+
embedded_in :para_base
|
144
|
+
end
|
145
|
+
|
146
|
+
class NormEmbedsManyPoly
|
147
|
+
include Mongoid::Document
|
148
|
+
|
149
|
+
embedded_in :base, polymorphic: true
|
150
|
+
end
|
151
|
+
|
152
|
+
class ParaHasOne
|
153
|
+
include Mongoid::Document
|
154
|
+
include Mongoid::Paranoia
|
155
|
+
|
156
|
+
belongs_to :norm_base
|
157
|
+
belongs_to :para_base
|
158
|
+
|
159
|
+
has_one :norm_belongs_to, dependent: :destroy
|
160
|
+
has_one :para_belongs_to, dependent: :destroy
|
161
|
+
|
162
|
+
has_one :norm_habtm, dependent: :destroy
|
163
|
+
has_one :norm_habtm, dependent: :destroy
|
164
|
+
end
|
165
|
+
|
166
|
+
class ParaHasMany
|
167
|
+
include Mongoid::Document
|
168
|
+
include Mongoid::Paranoia
|
169
|
+
|
170
|
+
belongs_to :norm_base
|
171
|
+
belongs_to :para_base
|
172
|
+
|
173
|
+
has_many :norm_belongs_to, dependent: :destroy
|
174
|
+
has_many :para_belongs_to, dependent: :destroy
|
175
|
+
|
176
|
+
has_many :norm_habtm, dependent: :destroy
|
177
|
+
has_many :norm_habtm, dependent: :destroy
|
178
|
+
end
|
179
|
+
|
180
|
+
class ParaHasManyPoly
|
181
|
+
include Mongoid::Document
|
182
|
+
include Mongoid::Paranoia
|
183
|
+
|
184
|
+
belongs_to :base, polymorphic: true
|
185
|
+
end
|
186
|
+
|
187
|
+
class ParaBelongsToOne
|
188
|
+
include Mongoid::Document
|
189
|
+
include Mongoid::Paranoia
|
190
|
+
|
191
|
+
has_one :norm_base
|
192
|
+
has_one :para_base
|
193
|
+
end
|
194
|
+
|
195
|
+
class ParaBelongsTo
|
196
|
+
include Mongoid::Document
|
197
|
+
include Mongoid::Paranoia
|
198
|
+
|
199
|
+
has_many :norm_base
|
200
|
+
has_many :para_base
|
201
|
+
|
202
|
+
belongs_to :norm_has_one, dependent: :destroy
|
203
|
+
belongs_to :para_has_one, dependent: :destroy
|
204
|
+
|
205
|
+
belongs_to :norm_has_many, dependent: :destroy
|
206
|
+
belongs_to :para_has_many, dependent: :destroy
|
207
|
+
end
|
208
|
+
|
209
|
+
class ParaHabtm
|
210
|
+
include Mongoid::Document
|
211
|
+
include Mongoid::Paranoia
|
212
|
+
|
213
|
+
has_and_belongs_to_many :norm_base
|
214
|
+
has_and_belongs_to_many :para_base
|
215
|
+
|
216
|
+
belongs_to :norm_has_one, dependent: :destroy
|
217
|
+
belongs_to :para_has_one, dependent: :destroy
|
218
|
+
|
219
|
+
belongs_to :norm_has_many, dependent: :destroy
|
220
|
+
belongs_to :para_has_many, dependent: :destroy
|
221
|
+
|
222
|
+
has_and_belongs_to_many :norm_habtm, dependent: :destroy
|
223
|
+
has_and_belongs_to_many :recursive, class_name: 'ParaHabtm', inverse_of: :recursive, dependent: :destroy
|
224
|
+
end
|
225
|
+
|
226
|
+
class ParaEmbedsOne
|
227
|
+
include Mongoid::Document
|
228
|
+
include Mongoid::Paranoia
|
229
|
+
|
230
|
+
embedded_in :norm_base
|
231
|
+
embedded_in :para_base
|
232
|
+
end
|
233
|
+
|
234
|
+
class ParaEmbedsMany
|
235
|
+
include Mongoid::Document
|
236
|
+
include Mongoid::Paranoia
|
237
|
+
|
238
|
+
embedded_in :norm_base
|
239
|
+
embedded_in :para_base
|
240
|
+
end
|
241
|
+
|
242
|
+
class ParaEmbedsManyPoly
|
243
|
+
include Mongoid::Document
|
244
|
+
include Mongoid::Paranoia
|
245
|
+
|
246
|
+
embedded_in :base, polymorphic: true
|
247
|
+
end
|