mongoid-versioning 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -8
  3. data/README.md +1 -1
  4. data/gemfiles/Mongoid_4.gemfile +4 -0
  5. data/gemfiles/Mongoid_5.gemfile +4 -0
  6. data/lib/mongoid/core_ext/fields/validators/macro.rb +1 -3
  7. data/lib/mongoid/core_ext/relations/options.rb +1 -3
  8. data/lib/mongoid/core_ext/versioning.rb +12 -3
  9. data/lib/mongoid/versioning/version.rb +1 -1
  10. data/mongoid-versioning.gemspec +3 -3
  11. data/spec/app/models/comment.rb +4 -4
  12. data/spec/mongoid/versioning_spec.rb +9 -5
  13. data/spec/spec_helper.rb +14 -2
  14. metadata +26 -187
  15. data/spec/app/models/account.rb +0 -28
  16. data/spec/app/models/acolyte.rb +0 -16
  17. data/spec/app/models/actor.rb +0 -19
  18. data/spec/app/models/actor_observer.rb +0 -15
  19. data/spec/app/models/actress.rb +0 -2
  20. data/spec/app/models/address_number.rb +0 -6
  21. data/spec/app/models/agency.rb +0 -5
  22. data/spec/app/models/agent.rb +0 -12
  23. data/spec/app/models/album.rb +0 -14
  24. data/spec/app/models/alert.rb +0 -5
  25. data/spec/app/models/animal.rb +0 -25
  26. data/spec/app/models/answer.rb +0 -4
  27. data/spec/app/models/appointment.rb +0 -7
  28. data/spec/app/models/article.rb +0 -10
  29. data/spec/app/models/artist.rb +0 -66
  30. data/spec/app/models/artwork.rb +0 -4
  31. data/spec/app/models/augmentation.rb +0 -11
  32. data/spec/app/models/band.rb +0 -25
  33. data/spec/app/models/bar.rb +0 -9
  34. data/spec/app/models/basic.rb +0 -6
  35. data/spec/app/models/bed.rb +0 -1
  36. data/spec/app/models/big_palette.rb +0 -2
  37. data/spec/app/models/birthday.rb +0 -13
  38. data/spec/app/models/book.rb +0 -12
  39. data/spec/app/models/breed.rb +0 -4
  40. data/spec/app/models/browser.rb +0 -6
  41. data/spec/app/models/building.rb +0 -5
  42. data/spec/app/models/building_address.rb +0 -5
  43. data/spec/app/models/bus.rb +0 -7
  44. data/spec/app/models/business.rb +0 -5
  45. data/spec/app/models/callback_recorder.rb +0 -25
  46. data/spec/app/models/callback_test.rb +0 -9
  47. data/spec/app/models/canvas.rb +0 -25
  48. data/spec/app/models/car.rb +0 -1
  49. data/spec/app/models/cat.rb +0 -8
  50. data/spec/app/models/category.rb +0 -8
  51. data/spec/app/models/child.rb +0 -4
  52. data/spec/app/models/child_doc.rb +0 -22
  53. data/spec/app/models/church.rb +0 -4
  54. data/spec/app/models/circle.rb +0 -3
  55. data/spec/app/models/circuit.rb +0 -4
  56. data/spec/app/models/circus.rb +0 -7
  57. data/spec/app/models/code.rb +0 -5
  58. data/spec/app/models/contractor.rb +0 -5
  59. data/spec/app/models/cookie.rb +0 -6
  60. data/spec/app/models/country_code.rb +0 -8
  61. data/spec/app/models/definition.rb +0 -7
  62. data/spec/app/models/description.rb +0 -11
  63. data/spec/app/models/dictionary.rb +0 -10
  64. data/spec/app/models/division.rb +0 -10
  65. data/spec/app/models/doctor.rb +0 -12
  66. data/spec/app/models/dog.rb +0 -6
  67. data/spec/app/models/dokument.rb +0 -5
  68. data/spec/app/models/driver.rb +0 -7
  69. data/spec/app/models/drug.rb +0 -6
  70. data/spec/app/models/email.rb +0 -6
  71. data/spec/app/models/employer.rb +0 -5
  72. data/spec/app/models/entry.rb +0 -6
  73. data/spec/app/models/eraser.rb +0 -1
  74. data/spec/app/models/event.rb +0 -22
  75. data/spec/app/models/exhibition.rb +0 -4
  76. data/spec/app/models/exhibitor.rb +0 -5
  77. data/spec/app/models/eye.rb +0 -9
  78. data/spec/app/models/eye_bowl.rb +0 -9
  79. data/spec/app/models/face.rb +0 -8
  80. data/spec/app/models/favorite.rb +0 -6
  81. data/spec/app/models/filesystem.rb +0 -4
  82. data/spec/app/models/firefox.rb +0 -4
  83. data/spec/app/models/fish.rb +0 -8
  84. data/spec/app/models/folder.rb +0 -7
  85. data/spec/app/models/folder_item.rb +0 -9
  86. data/spec/app/models/fruits.rb +0 -28
  87. data/spec/app/models/game.rb +0 -19
  88. data/spec/app/models/ghost.rb +0 -7
  89. data/spec/app/models/home.rb +0 -4
  90. data/spec/app/models/house.rb +0 -7
  91. data/spec/app/models/html_writer.rb +0 -3
  92. data/spec/app/models/image.rb +0 -22
  93. data/spec/app/models/implant.rb +0 -16
  94. data/spec/app/models/item.rb +0 -8
  95. data/spec/app/models/jar.rb +0 -7
  96. data/spec/app/models/label.rb +0 -40
  97. data/spec/app/models/language.rb +0 -5
  98. data/spec/app/models/lat_lng.rb +0 -15
  99. data/spec/app/models/league.rb +0 -11
  100. data/spec/app/models/learner.rb +0 -2
  101. data/spec/app/models/line_item.rb +0 -6
  102. data/spec/app/models/location.rb +0 -8
  103. data/spec/app/models/login.rb +0 -8
  104. data/spec/app/models/manufacturer.rb +0 -7
  105. data/spec/app/models/meat.rb +0 -4
  106. data/spec/app/models/membership.rb +0 -4
  107. data/spec/app/models/mixed_drink.rb +0 -4
  108. data/spec/app/models/movie.rb +0 -12
  109. data/spec/app/models/my_hash.rb +0 -2
  110. data/spec/app/models/name.rb +0 -21
  111. data/spec/app/models/node.rb +0 -5
  112. data/spec/app/models/note.rb +0 -12
  113. data/spec/app/models/ordered_post.rb +0 -6
  114. data/spec/app/models/ordered_preference.rb +0 -6
  115. data/spec/app/models/oscar.rb +0 -15
  116. data/spec/app/models/override.rb +0 -16
  117. data/spec/app/models/ownable.rb +0 -6
  118. data/spec/app/models/owner.rb +0 -6
  119. data/spec/app/models/page.rb +0 -5
  120. data/spec/app/models/page_question.rb +0 -4
  121. data/spec/app/models/palette.rb +0 -7
  122. data/spec/app/models/paranoid_phone.rb +0 -27
  123. data/spec/app/models/parent.rb +0 -5
  124. data/spec/app/models/parent_doc.rb +0 -6
  125. data/spec/app/models/passport.rb +0 -5
  126. data/spec/app/models/patient.rb +0 -9
  127. data/spec/app/models/pdf_writer.rb +0 -3
  128. data/spec/app/models/pencil.rb +0 -1
  129. data/spec/app/models/person.rb +0 -198
  130. data/spec/app/models/pet.rb +0 -23
  131. data/spec/app/models/pet_owner.rb +0 -6
  132. data/spec/app/models/phone.rb +0 -11
  133. data/spec/app/models/phone_observer.rb +0 -6
  134. data/spec/app/models/pizza.rb +0 -7
  135. data/spec/app/models/player.rb +0 -35
  136. data/spec/app/models/post.rb +0 -42
  137. data/spec/app/models/powerup.rb +0 -11
  138. data/spec/app/models/preference.rb +0 -9
  139. data/spec/app/models/princess.rb +0 -8
  140. data/spec/app/models/product.rb +0 -15
  141. data/spec/app/models/profile.rb +0 -5
  142. data/spec/app/models/pronunciation.rb +0 -5
  143. data/spec/app/models/purchase.rb +0 -4
  144. data/spec/app/models/question.rb +0 -8
  145. data/spec/app/models/quiz.rb +0 -7
  146. data/spec/app/models/rating.rb +0 -8
  147. data/spec/app/models/record.rb +0 -46
  148. data/spec/app/models/registry.rb +0 -4
  149. data/spec/app/models/role.rb +0 -5
  150. data/spec/app/models/root_category.rb +0 -4
  151. data/spec/app/models/sandwich.rb +0 -4
  152. data/spec/app/models/scheduler.rb +0 -7
  153. data/spec/app/models/seo.rb +0 -7
  154. data/spec/app/models/series.rb +0 -4
  155. data/spec/app/models/server.rb +0 -13
  156. data/spec/app/models/service.rb +0 -22
  157. data/spec/app/models/shape.rb +0 -12
  158. data/spec/app/models/shelf.rb +0 -5
  159. data/spec/app/models/shipping_container.rb +0 -5
  160. data/spec/app/models/shop.rb +0 -6
  161. data/spec/app/models/short_agent.rb +0 -4
  162. data/spec/app/models/short_quiz.rb +0 -5
  163. data/spec/app/models/slave.rb +0 -6
  164. data/spec/app/models/song.rb +0 -8
  165. data/spec/app/models/square.rb +0 -4
  166. data/spec/app/models/strategy.rb +0 -3
  167. data/spec/app/models/sub_item.rb +0 -3
  168. data/spec/app/models/survey.rb +0 -5
  169. data/spec/app/models/symptom.rb +0 -6
  170. data/spec/app/models/target.rb +0 -5
  171. data/spec/app/models/template.rb +0 -5
  172. data/spec/app/models/thing.rb +0 -9
  173. data/spec/app/models/tool.rb +0 -8
  174. data/spec/app/models/topping.rb +0 -5
  175. data/spec/app/models/track.rb +0 -38
  176. data/spec/app/models/translation.rb +0 -5
  177. data/spec/app/models/tree.rb +0 -9
  178. data/spec/app/models/truck.rb +0 -3
  179. data/spec/app/models/user.rb +0 -20
  180. data/spec/app/models/user_account.rb +0 -10
  181. data/spec/app/models/validation_callback.rb +0 -10
  182. data/spec/app/models/vehicle.rb +0 -11
  183. data/spec/app/models/version.rb +0 -5
  184. data/spec/app/models/vet_visit.rb +0 -5
  185. data/spec/app/models/video.rb +0 -13
  186. data/spec/app/models/weapon.rb +0 -11
  187. data/spec/app/models/word.rb +0 -12
  188. data/spec/app/models/word_origin.rb +0 -11
  189. data/spec/app/models/writer.rb +0 -11
@@ -1,198 +0,0 @@
1
- class Person
2
- include Mongoid::Document
3
- attr_accessor :mode
4
-
5
- class_attribute :somebody_elses_important_class_options
6
- self.somebody_elses_important_class_options = { keep_me_around: true }
7
-
8
- field :username, default: -> { "arthurnn#{rand(0..10)}" }
9
- field :title
10
- field :terms, type: Boolean
11
- field :pets, type: Boolean, default: false
12
- field :age, type: Integer, default: "100"
13
- field :dob, type: Date
14
- field :employer_id
15
- field :lunch_time, type: Time
16
- field :aliases, type: Array
17
- field :map, type: Hash
18
- field :map_with_default, type: Hash, default: {}
19
- field :score, type: Integer
20
- field :blood_alcohol_content, type: Float, default: ->{ 0.0 }
21
- field :last_drink_taken_at, type: Date, default: ->{ 1.day.ago.in_time_zone("Alaska") }
22
- field :ssn
23
- field :owner_id, type: Integer
24
- field :security_code
25
- field :reading, type: Object
26
- field :bson_id, type: BSON::ObjectId
27
- field :pattern, type: Regexp
28
- field :override_me, type: Integer
29
- field :t, as: :test, type: String
30
- field :i, as: :inte, type: Integer
31
- field :a, as: :array, type: Array
32
- field :desc, localize: true
33
-
34
- index age: 1
35
- index addresses: 1
36
- index dob: 1
37
- index name: 1
38
- index title: 1
39
-
40
- index({ ssn: 1 }, { unique: true })
41
-
42
- attr_reader :rescored
43
-
44
- embeds_many :favorites, order: :title.desc, inverse_of: :perp, validate: false
45
- embeds_many :videos, order: [[ :title, :asc ]], validate: false
46
- embeds_many :phone_numbers, class_name: "Phone", validate: false
47
- embeds_many :phones, store_as: :mobile_phones, validate: false
48
- embeds_many :addresses, as: :addressable, validate: false do
49
- def extension
50
- "Testing"
51
- end
52
- def find_by_street(street)
53
- where(street: street).first
54
- end
55
- end
56
-
57
- embeds_many :address_components, validate: false
58
- embeds_many :paranoid_phones, validate: false
59
- embeds_many :services, cascade_callbacks: true, validate: false
60
- embeds_many :symptoms, validate: false
61
- embeds_many :appointments, validate: false
62
-
63
- embeds_one :passport, autobuild: true, store_as: :pass, validate: false
64
- embeds_one :pet, class_name: "Animal", validate: false
65
- embeds_one :name, as: :namable, validate: false do
66
- def extension
67
- "Testing"
68
- end
69
- def dawkins?
70
- first_name == "Richard" && last_name == "Dawkins"
71
- end
72
- end
73
- embeds_one :quiz, validate: false
74
-
75
- has_one :game, dependent: :destroy, validate: false do
76
- def extension
77
- "Testing"
78
- end
79
- end
80
-
81
- has_many \
82
- :posts,
83
- dependent: :delete,
84
- validate: false do
85
- def extension
86
- "Testing"
87
- end
88
- end
89
- has_many :ordered_posts, order: :rating.desc, validate: false
90
- has_many :paranoid_posts, validate: false
91
- has_and_belongs_to_many \
92
- :preferences,
93
- index: true,
94
- dependent: :nullify,
95
- validate: false
96
- has_and_belongs_to_many :user_accounts, validate: false
97
- has_and_belongs_to_many :houses, validate: false
98
- has_and_belongs_to_many :ordered_preferences, order: :value.desc, validate: false
99
-
100
- has_many :drugs, validate: false
101
- has_one :account, validate: false
102
- has_one :cat, dependent: :nullify, validate: false, primary_key: :username
103
- has_one :book, autobuild: true, validate: false
104
- has_one :home, dependent: :delete, validate: false
105
-
106
- has_and_belongs_to_many \
107
- :administrated_events,
108
- class_name: 'Event',
109
- inverse_of: :administrators,
110
- dependent: :nullify,
111
- validate: false
112
-
113
- accepts_nested_attributes_for :addresses
114
- accepts_nested_attributes_for :paranoid_phones
115
- accepts_nested_attributes_for :name, update_only: true
116
- accepts_nested_attributes_for :pet, allow_destroy: true
117
- accepts_nested_attributes_for :game, allow_destroy: true
118
- accepts_nested_attributes_for :favorites, allow_destroy: true, limit: 5
119
- accepts_nested_attributes_for :posts
120
- accepts_nested_attributes_for :preferences
121
- accepts_nested_attributes_for :quiz
122
- accepts_nested_attributes_for :services, allow_destroy: true
123
-
124
- scope :minor, ->{ where(:age.lt => 18) }
125
- scope :without_ssn, ->{ without(:ssn) }
126
- scope :search, ->(query){ any_of({ title: query }) }
127
-
128
- def score_with_rescoring=(score)
129
- @rescored = score.to_i + 20
130
- self.score_without_rescoring = score
131
- end
132
-
133
- alias_method_chain :score=, :rescoring
134
-
135
- def update_addresses
136
- addresses.each do |address|
137
- address.street = "Updated Address"
138
- end
139
- end
140
-
141
- def employer=(emp)
142
- self.employer_id = emp.id
143
- end
144
-
145
- def set_addresses=(addresses)
146
- self.addresses = addresses
147
- end
148
-
149
- def override_me
150
- read_attribute(:override_me).to_s
151
- end
152
-
153
- class << self
154
- def accepted
155
- scoped.where(terms: true)
156
- end
157
- def knight
158
- scoped.where(title: "Sir")
159
- end
160
- def old
161
- scoped.where(age: { "$gt" => 50 })
162
- end
163
- end
164
-
165
- def reject_if_city_is_empty(attrs)
166
- attrs[:city].blank?
167
- end
168
-
169
- def reject_if_name_is_blank(attrs)
170
- attrs[:first_name].blank?
171
- end
172
-
173
- def foo
174
- 'i_am_foo'
175
- end
176
-
177
- def preference_names=(names)
178
- names.split(",").each do |name|
179
- preference = Preference.where(name: name).first
180
- if preference
181
- self.preferences << preference
182
- else
183
- preferences.build(name: name)
184
- end
185
- end
186
- end
187
-
188
- def set_on_map_with_default=(value)
189
- self.map_with_default["key"] = value
190
- end
191
-
192
- reset_callbacks(:validate)
193
- reset_callbacks(:create)
194
- reset_callbacks(:save)
195
- reset_callbacks(:destroy)
196
- end
197
-
198
- require "app/models/doctor"
@@ -1,23 +0,0 @@
1
- class Pet
2
- include Mongoid::Document
3
- field :name
4
- field :weight, type: Float, default: 0.0
5
- embeds_many :vet_visits
6
- embedded_in :pet_owner
7
-
8
- after_destroy :set_destroy_flag
9
- attr_writer :destroy_flag
10
-
11
- def set_destroy_flag
12
- @destroy_flag = true
13
- end
14
-
15
- def destroy_flag
16
- @destroy_flag ||= false
17
- end
18
-
19
- def visits_count=(count)
20
- vet_visits.destroy_all
21
- count.times { vet_visits.new }
22
- end
23
- end
@@ -1,6 +0,0 @@
1
- class PetOwner
2
- include Mongoid::Document
3
- field :title
4
- embeds_one :pet, cascade_callbacks: true
5
- embeds_one :address, as: :addressable
6
- end
@@ -1,11 +0,0 @@
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,6 +0,0 @@
1
- class PhoneObserver < Mongoid::Observer
2
-
3
- def after_save(phone)
4
- phone.number_in_observer = phone.number
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- class Pizza
2
- include Mongoid::Document
3
- field :name, type: String
4
- has_one :topping, autosave: true
5
- validates_presence_of :topping
6
- accepts_nested_attributes_for :topping
7
- end
@@ -1,35 +0,0 @@
1
- class Player
2
- include Mongoid::Document
3
- field :active, type: Boolean
4
- field :frags, type: Integer
5
- field :deaths, type: Integer
6
- field :impressions, type: Integer, default: 0
7
- field :status
8
-
9
- scope :active, ->{ where(active: true) } do
10
- def extension
11
- "extension"
12
- end
13
- end
14
-
15
- scope :inactive, ->{ where(active: false) }
16
- scope :frags_over, ->(count) { where(:frags.gt => count) }
17
- scope :deaths_under, ->(count) { where(:deaths.lt => count) }
18
- scope :deaths_over, ->(count) { where(:deaths.gt => count) }
19
-
20
- has_many :weapons
21
- has_one :powerup
22
-
23
- embeds_many :implants
24
- embeds_one :augmentation
25
-
26
- after_find do |doc|
27
- doc.impressions += 1
28
- end
29
-
30
- class << self
31
- def alive
32
- where(status: "Alive")
33
- end
34
- end
35
- end
@@ -1,42 +0,0 @@
1
- class Post
2
- include Mongoid::Document
3
-
4
- field :title, type: String
5
- field :content, type: String
6
- field :rating, type: Integer
7
- field :person_title, type: String, default: ->{ person.try(:title) }
8
-
9
- attr_accessor :before_add_called, :after_add_called, :before_remove_called, :after_remove_called
10
-
11
- belongs_to :person, counter_cache: true
12
- belongs_to :author, foreign_key: :author_id, class_name: "User"
13
- has_and_belongs_to_many :tags, before_add: :before_add_tag, after_add: :after_add_tag, before_remove: :before_remove_tag, after_remove: :after_remove_tag
14
- has_many :videos, validate: false
15
-
16
- scope :recent, ->{ where(created_at: { "$lt" => Time.now, "$gt" => 30.days.ago }) }
17
- scope :posting, ->{ where(:content.in => [ "Posting" ]) }
18
-
19
- validates_format_of :title, without: /\$\$\$/
20
-
21
- def before_add_tag(tag)
22
- @before_add_called = true
23
- end
24
-
25
- def after_add_tag(tag)
26
- @after_add_called = true
27
- end
28
-
29
- def before_remove_tag(tag)
30
- @before_remove_called = true
31
- end
32
-
33
- def after_remove_tag(tag)
34
- @after_remove_called = true
35
- end
36
-
37
- class << self
38
- def old
39
- where(created_at: { "$lt" => 30.days.ago })
40
- end
41
- end
42
- end
@@ -1,11 +0,0 @@
1
- class Powerup
2
- include Mongoid::Document
3
-
4
- field :name
5
-
6
- belongs_to :player, inverse_of: :powerup
7
-
8
- after_build do
9
- self.name = "Quad Damage (#{player.frags})"
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- class Preference
2
- include Mongoid::Document
3
- field :name, type: String
4
- field :value, type: String
5
- field :ranking, type: Integer
6
- has_and_belongs_to_many :people, validate: false
7
- validates_length_of :name, minimum: 2, allow_nil: true
8
- scope :posting, ->{ where(:value.in => [ "Posting" ]) }
9
- end
@@ -1,8 +0,0 @@
1
- class Princess
2
- include Mongoid::Document
3
- field :primary_color
4
- def color
5
- primary_color.to_s
6
- end
7
- validates_presence_of :color
8
- end
@@ -1,15 +0,0 @@
1
- class Product
2
- include Mongoid::Document
3
- field :description, localize: true
4
- field :name, localize: true, default: "no translation"
5
- field :price, type: Integer
6
- field :brand_name
7
- field :stores, type: Array
8
- field :website, localize: true
9
- alias_attribute :cost, :price
10
-
11
- validates :name, presence: true
12
- validates :website, format: { with: URI.regexp, allow_blank: true }
13
-
14
- embeds_one :seo, as: :seo_tags, cascade_callbacks: true, autobuild: true
15
- end
@@ -1,5 +0,0 @@
1
- class Profile
2
- include Mongoid::Document
3
- field :name, type: String
4
- shard_key :name
5
- end
@@ -1,5 +0,0 @@
1
- class Pronunciation
2
- include Mongoid::Document
3
- field :sound, type: String
4
- embedded_in :word
5
- end
@@ -1,4 +0,0 @@
1
- class Purchase
2
- include Mongoid::Document
3
- embeds_many :line_items
4
- end
@@ -1,8 +0,0 @@
1
- class Question
2
- include Mongoid::Document
3
- field :content
4
- embedded_in :survey
5
- embeds_many :answers
6
-
7
- accepts_nested_attributes_for :answers, reject_if: ->(a){ a[:content].blank? }, allow_destroy: true
8
- end
@@ -1,7 +0,0 @@
1
- class Quiz
2
- include Mongoid::Document
3
- include Mongoid::Timestamps::Created
4
- field :name, type: String
5
- field :topic, type: String
6
- embeds_many :pages
7
- end
@@ -1,8 +0,0 @@
1
- class Rating
2
- include Mongoid::Document
3
- field :value, type: Integer
4
- belongs_to :ratable, polymorphic: true
5
- has_many :comments
6
- validates_numericality_of :value, less_than: 100, allow_nil: true
7
- validates :ratable, associated: true
8
- end
@@ -1,46 +0,0 @@
1
- class Record
2
- include Mongoid::Document
3
- field :name, type: String
4
-
5
- field :before_create_called, type: Boolean, default: false
6
- field :before_save_called, type: Boolean, default: false
7
- field :before_update_called, type: Boolean, default: false
8
- field :before_validation_called, type: Boolean, default: false
9
- field :before_destroy_called, type: Boolean, default: false
10
-
11
- embedded_in :band
12
- embeds_many :tracks, cascade_callbacks: true
13
- embeds_many :notes, as: :noteable, cascade_callbacks: true, validate: false
14
-
15
- before_create :before_create_stub
16
- before_save :before_save_stub
17
- before_update :before_update_stub
18
- before_validation :before_validation_stub
19
- before_destroy :before_destroy_stub
20
-
21
- after_destroy :access_band
22
-
23
- def before_create_stub
24
- self.before_create_called = true
25
- end
26
-
27
- def before_save_stub
28
- self.before_save_called = true
29
- end
30
-
31
- def before_update_stub
32
- self.before_update_called = true
33
- end
34
-
35
- def before_validation_stub
36
- self.before_validation_called = true
37
- end
38
-
39
- def before_destroy_stub
40
- self.before_destroy_called = true
41
- end
42
-
43
- def access_band
44
- band.name
45
- end
46
- end
@@ -1,4 +0,0 @@
1
- class Registry
2
- include Mongoid::Document
3
- field :data, type: BSON::Binary
4
- end
@@ -1,5 +0,0 @@
1
- class Role
2
- include Mongoid::Document
3
- field :name, type: String
4
- recursively_embeds_many
5
- end
@@ -1,4 +0,0 @@
1
- class RootCategory
2
- include Mongoid::Document
3
- embeds_many :categories
4
- end
@@ -1,4 +0,0 @@
1
- class Sandwich
2
- include Mongoid::Document
3
- has_and_belongs_to_many :meats
4
- end
@@ -1,7 +0,0 @@
1
- class Scheduler
2
- include Mongoid::Document
3
-
4
- def strategy
5
- Strategy.new
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- class Seo
2
- include Mongoid::Document
3
- include Mongoid::Timestamps
4
- field :title, type: String
5
-
6
- embedded_in :seo_tags, polymorphic: true
7
- end
@@ -1,4 +0,0 @@
1
- class Series
2
- include Mongoid::Document
3
- has_many :books
4
- end
@@ -1,13 +0,0 @@
1
- class Server
2
- include Mongoid::Document
3
- field :name, type: String
4
- field :after, type: Boolean, default: false
5
- belongs_to :node
6
- embeds_many :filesystems, validate: false
7
- accepts_nested_attributes_for :filesystems
8
- validates :name, presence: { allow_blank: false }
9
-
10
- after_create do |server|
11
- server.update_attribute(:after, !after)
12
- end
13
- end
@@ -1,22 +0,0 @@
1
- class Service
2
- include Mongoid::Document
3
- field :sid
4
- field :before_destroy_called, type: Boolean, default: false
5
- field :after_destroy_called, type: Boolean, default: false
6
- field :after_initialize_called, type: Boolean, default: false
7
- embedded_in :person
8
- belongs_to :target, class_name: "User"
9
- validates_numericality_of :sid
10
-
11
- before_destroy do |doc|
12
- doc.before_destroy_called = true
13
- end
14
-
15
- after_destroy do |doc|
16
- doc.after_destroy_called = true
17
- end
18
-
19
- after_initialize do |doc|
20
- doc.after_initialize_called = true
21
- end
22
- end
@@ -1,12 +0,0 @@
1
- class Shape
2
- include Mongoid::Document
3
- field :x, type: Integer, default: 0
4
- field :y, type: Integer, default: 0
5
-
6
- embedded_in :canvas
7
-
8
- def render; end
9
- end
10
-
11
- require "app/models/circle"
12
- require "app/models/square"
@@ -1,5 +0,0 @@
1
- class Shelf
2
- include Mongoid::Document
3
- field :level, type: Integer
4
- recursively_embeds_one
5
- end
@@ -1,5 +0,0 @@
1
- class ShippingContainer
2
- include Mongoid::Document
3
- has_many :vehicles
4
- accepts_nested_attributes_for :vehicles
5
- end
@@ -1,6 +0,0 @@
1
- class Shop
2
- include Mongoid::Document
3
- field :title, type: String
4
- has_and_belongs_to_many :followers, inverse_of: :followed_shops, class_name: "User"
5
- belongs_to :user
6
- end
@@ -1,4 +0,0 @@
1
- class ShortAgent
2
- include Mongoid::Document
3
- include Mongoid::Timestamps::Updated::Short
4
- end
@@ -1,5 +0,0 @@
1
- class ShortQuiz
2
- include Mongoid::Document
3
- include Mongoid::Timestamps::Created::Short
4
- field :name, type: String
5
- end
@@ -1,6 +0,0 @@
1
- class Slave
2
- include Mongoid::Document
3
- field :first_name
4
- field :last_name
5
- embeds_many :address_numbers
6
- end
@@ -1,8 +0,0 @@
1
- class Song
2
- include Mongoid::Document
3
- field :title
4
- embedded_in :artist
5
-
6
- attr_accessor :before_add_called
7
-
8
- end
@@ -1,4 +0,0 @@
1
- class Square < Shape
2
- field :width, type: Integer, default: 0
3
- field :height, type: Integer, default: 0
4
- end
@@ -1,3 +0,0 @@
1
- class Strategy
2
- include Mongoid::Document
3
- end
@@ -1,3 +0,0 @@
1
- class SubItem < Item
2
- embedded_in :parent
3
- end
@@ -1,5 +0,0 @@
1
- class Survey
2
- include Mongoid::Document
3
- embeds_many :questions
4
- accepts_nested_attributes_for :questions, reject_if: ->(a){ a[:content].blank? }, allow_destroy: true
5
- end
@@ -1,6 +0,0 @@
1
- class Symptom
2
- include Mongoid::Document
3
- field :name, type: String
4
- embedded_in :person
5
- default_scope ->{ asc(:name) }
6
- end
@@ -1,5 +0,0 @@
1
- class Target
2
- include Mongoid::Document
3
- field :name, type: String
4
- embedded_in :targetable, polymorphic: true
5
- end