mongoid-paranoia 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -0
  3. data/gemfiles/Mongoid_4.gemfile +4 -0
  4. data/gemfiles/Mongoid_5.gemfile +4 -0
  5. data/lib/mongoid/paranoia/version.rb +1 -1
  6. data/mongoid-paranoia.gemspec +3 -2
  7. data/spec/spec_helper.rb +9 -2
  8. metadata +16 -173
  9. data/spec/app/models/account.rb +0 -28
  10. data/spec/app/models/acolyte.rb +0 -16
  11. data/spec/app/models/actor.rb +0 -19
  12. data/spec/app/models/actor_observer.rb +0 -15
  13. data/spec/app/models/actress.rb +0 -2
  14. data/spec/app/models/address_number.rb +0 -6
  15. data/spec/app/models/agency.rb +0 -5
  16. data/spec/app/models/agent.rb +0 -12
  17. data/spec/app/models/album.rb +0 -14
  18. data/spec/app/models/alert.rb +0 -5
  19. data/spec/app/models/animal.rb +0 -25
  20. data/spec/app/models/answer.rb +0 -4
  21. data/spec/app/models/article.rb +0 -10
  22. data/spec/app/models/artist.rb +0 -66
  23. data/spec/app/models/artwork.rb +0 -4
  24. data/spec/app/models/augmentation.rb +0 -11
  25. data/spec/app/models/band.rb +0 -25
  26. data/spec/app/models/bar.rb +0 -9
  27. data/spec/app/models/basic.rb +0 -6
  28. data/spec/app/models/bed.rb +0 -1
  29. data/spec/app/models/big_palette.rb +0 -2
  30. data/spec/app/models/birthday.rb +0 -13
  31. data/spec/app/models/book.rb +0 -12
  32. data/spec/app/models/breed.rb +0 -4
  33. data/spec/app/models/browser.rb +0 -6
  34. data/spec/app/models/building.rb +0 -5
  35. data/spec/app/models/building_address.rb +0 -5
  36. data/spec/app/models/bus.rb +0 -7
  37. data/spec/app/models/business.rb +0 -5
  38. data/spec/app/models/callback_recorder.rb +0 -25
  39. data/spec/app/models/callback_test.rb +0 -9
  40. data/spec/app/models/canvas.rb +0 -25
  41. data/spec/app/models/car.rb +0 -1
  42. data/spec/app/models/cat.rb +0 -8
  43. data/spec/app/models/category.rb +0 -8
  44. data/spec/app/models/child.rb +0 -4
  45. data/spec/app/models/child_doc.rb +0 -22
  46. data/spec/app/models/church.rb +0 -4
  47. data/spec/app/models/circle.rb +0 -3
  48. data/spec/app/models/circuit.rb +0 -4
  49. data/spec/app/models/circus.rb +0 -7
  50. data/spec/app/models/code.rb +0 -5
  51. data/spec/app/models/comment.rb +0 -16
  52. data/spec/app/models/contractor.rb +0 -5
  53. data/spec/app/models/cookie.rb +0 -6
  54. data/spec/app/models/country_code.rb +0 -8
  55. data/spec/app/models/definition.rb +0 -7
  56. data/spec/app/models/description.rb +0 -11
  57. data/spec/app/models/dictionary.rb +0 -10
  58. data/spec/app/models/division.rb +0 -10
  59. data/spec/app/models/dog.rb +0 -6
  60. data/spec/app/models/dokument.rb +0 -5
  61. data/spec/app/models/driver.rb +0 -7
  62. data/spec/app/models/drug.rb +0 -6
  63. data/spec/app/models/email.rb +0 -6
  64. data/spec/app/models/employer.rb +0 -5
  65. data/spec/app/models/entry.rb +0 -6
  66. data/spec/app/models/eraser.rb +0 -1
  67. data/spec/app/models/event.rb +0 -22
  68. data/spec/app/models/exhibition.rb +0 -4
  69. data/spec/app/models/exhibitor.rb +0 -5
  70. data/spec/app/models/eye.rb +0 -9
  71. data/spec/app/models/eye_bowl.rb +0 -9
  72. data/spec/app/models/face.rb +0 -8
  73. data/spec/app/models/filesystem.rb +0 -4
  74. data/spec/app/models/firefox.rb +0 -4
  75. data/spec/app/models/folder.rb +0 -7
  76. data/spec/app/models/folder_item.rb +0 -9
  77. data/spec/app/models/fruits.rb +0 -28
  78. data/spec/app/models/game.rb +0 -19
  79. data/spec/app/models/ghost.rb +0 -7
  80. data/spec/app/models/home.rb +0 -4
  81. data/spec/app/models/house.rb +0 -7
  82. data/spec/app/models/html_writer.rb +0 -3
  83. data/spec/app/models/image.rb +0 -22
  84. data/spec/app/models/implant.rb +0 -16
  85. data/spec/app/models/item.rb +0 -8
  86. data/spec/app/models/jar.rb +0 -7
  87. data/spec/app/models/label.rb +0 -40
  88. data/spec/app/models/language.rb +0 -5
  89. data/spec/app/models/lat_lng.rb +0 -15
  90. data/spec/app/models/league.rb +0 -11
  91. data/spec/app/models/learner.rb +0 -2
  92. data/spec/app/models/line_item.rb +0 -6
  93. data/spec/app/models/login.rb +0 -8
  94. data/spec/app/models/manufacturer.rb +0 -7
  95. data/spec/app/models/meat.rb +0 -4
  96. data/spec/app/models/membership.rb +0 -4
  97. data/spec/app/models/mixed_drink.rb +0 -4
  98. data/spec/app/models/movie.rb +0 -12
  99. data/spec/app/models/my_hash.rb +0 -2
  100. data/spec/app/models/name.rb +0 -21
  101. data/spec/app/models/node.rb +0 -5
  102. data/spec/app/models/note.rb +0 -12
  103. data/spec/app/models/ordered_post.rb +0 -6
  104. data/spec/app/models/ordered_preference.rb +0 -6
  105. data/spec/app/models/oscar.rb +0 -15
  106. data/spec/app/models/override.rb +0 -16
  107. data/spec/app/models/ownable.rb +0 -6
  108. data/spec/app/models/owner.rb +0 -6
  109. data/spec/app/models/page.rb +0 -5
  110. data/spec/app/models/page_question.rb +0 -4
  111. data/spec/app/models/palette.rb +0 -7
  112. data/spec/app/models/parent.rb +0 -5
  113. data/spec/app/models/parent_doc.rb +0 -6
  114. data/spec/app/models/passport.rb +0 -5
  115. data/spec/app/models/patient.rb +0 -9
  116. data/spec/app/models/pdf_writer.rb +0 -3
  117. data/spec/app/models/pencil.rb +0 -1
  118. data/spec/app/models/pet.rb +0 -23
  119. data/spec/app/models/pet_owner.rb +0 -6
  120. data/spec/app/models/phone_observer.rb +0 -6
  121. data/spec/app/models/pizza.rb +0 -7
  122. data/spec/app/models/player.rb +0 -35
  123. data/spec/app/models/post.rb +0 -42
  124. data/spec/app/models/powerup.rb +0 -11
  125. data/spec/app/models/preference.rb +0 -9
  126. data/spec/app/models/princess.rb +0 -8
  127. data/spec/app/models/product.rb +0 -15
  128. data/spec/app/models/profile.rb +0 -5
  129. data/spec/app/models/pronunciation.rb +0 -5
  130. data/spec/app/models/purchase.rb +0 -4
  131. data/spec/app/models/question.rb +0 -8
  132. data/spec/app/models/quiz.rb +0 -7
  133. data/spec/app/models/rating.rb +0 -8
  134. data/spec/app/models/record.rb +0 -46
  135. data/spec/app/models/registry.rb +0 -4
  136. data/spec/app/models/role.rb +0 -5
  137. data/spec/app/models/root_category.rb +0 -4
  138. data/spec/app/models/sandwich.rb +0 -4
  139. data/spec/app/models/scheduler.rb +0 -7
  140. data/spec/app/models/seo.rb +0 -7
  141. data/spec/app/models/series.rb +0 -4
  142. data/spec/app/models/server.rb +0 -13
  143. data/spec/app/models/shape.rb +0 -12
  144. data/spec/app/models/shelf.rb +0 -5
  145. data/spec/app/models/shipping_container.rb +0 -5
  146. data/spec/app/models/shop.rb +0 -6
  147. data/spec/app/models/short_agent.rb +0 -4
  148. data/spec/app/models/short_quiz.rb +0 -5
  149. data/spec/app/models/slave.rb +0 -6
  150. data/spec/app/models/song.rb +0 -8
  151. data/spec/app/models/square.rb +0 -4
  152. data/spec/app/models/strategy.rb +0 -3
  153. data/spec/app/models/sub_item.rb +0 -3
  154. data/spec/app/models/survey.rb +0 -5
  155. data/spec/app/models/target.rb +0 -5
  156. data/spec/app/models/template.rb +0 -5
  157. data/spec/app/models/thing.rb +0 -9
  158. data/spec/app/models/tool.rb +0 -8
  159. data/spec/app/models/topping.rb +0 -5
  160. data/spec/app/models/track.rb +0 -38
  161. data/spec/app/models/translation.rb +0 -5
  162. data/spec/app/models/tree.rb +0 -9
  163. data/spec/app/models/truck.rb +0 -3
  164. data/spec/app/models/user.rb +0 -20
  165. data/spec/app/models/user_account.rb +0 -10
  166. data/spec/app/models/validation_callback.rb +0 -10
  167. data/spec/app/models/vehicle.rb +0 -11
  168. data/spec/app/models/version.rb +0 -5
  169. data/spec/app/models/vet_visit.rb +0 -5
  170. data/spec/app/models/weapon.rb +0 -11
  171. data/spec/app/models/wiki_page.rb +0 -15
  172. data/spec/app/models/word.rb +0 -12
  173. data/spec/app/models/word_origin.rb +0 -11
  174. data/spec/app/models/writer.rb +0 -11
@@ -1,5 +0,0 @@
1
- class Language
2
- include Mongoid::Document
3
- field :name, type: String
4
- embedded_in :translatable, polymorphic: true
5
- end
@@ -1,15 +0,0 @@
1
- class LatLng
2
- attr_accessor :lat, :lng
3
-
4
- def self.demongoize(object)
5
- LatLng.new(object[1], object[0])
6
- end
7
-
8
- def initialize(lat, lng)
9
- @lat, @lng = lat, lng
10
- end
11
-
12
- def mongoize
13
- [ lng, lat ]
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- class League
2
- include Mongoid::Document
3
- field :name, type: String
4
- embeds_many :divisions
5
- accepts_nested_attributes_for :divisions, allow_destroy: true
6
- before_destroy :destroy_children
7
-
8
- def destroy_children
9
- divisions.destroy_all
10
- end
11
- end
@@ -1,2 +0,0 @@
1
- class Learner < Driver
2
- end
@@ -1,6 +0,0 @@
1
- class LineItem
2
- include Mongoid::Document
3
- embedded_in :purchase
4
- belongs_to :product, polymorphic: true
5
- validates :product, presence: true
6
- end
@@ -1,8 +0,0 @@
1
- class Login
2
- include Mongoid::Document
3
-
4
- field :_id, type: String, default: ->{ username }
5
-
6
- field :username, type: String
7
- field :application_id, type: Integer
8
- end
@@ -1,7 +0,0 @@
1
- class Manufacturer
2
- include Mongoid::Document
3
-
4
- field :products, type: Array, default: []
5
-
6
- validates_presence_of :products
7
- end
@@ -1,4 +0,0 @@
1
- class Meat
2
- include Mongoid::Document
3
- has_and_belongs_to_many :sandwiches
4
- end
@@ -1,4 +0,0 @@
1
- class Membership
2
- include Mongoid::Document
3
- embedded_in :account
4
- end
@@ -1,4 +0,0 @@
1
- class MixedDrink
2
- include Mongoid::Document
3
- field :name
4
- end
@@ -1,12 +0,0 @@
1
- class Movie
2
- include Mongoid::Document
3
- field :title, type: String
4
- field :poster, type: Image
5
- field :poster_thumb, type: Thumbnail
6
- has_many :ratings, as: :ratable, dependent: :nullify
7
- has_many :comments
8
-
9
- def global_set
10
- Set.new
11
- end
12
- end
@@ -1,2 +0,0 @@
1
- class MyHash < ::Hash
2
- end
@@ -1,21 +0,0 @@
1
- class Name
2
- include Mongoid::Document
3
-
4
- field :_id, type: String, default: ->{
5
- "#{first_name}-#{last_name}"
6
- }
7
-
8
- field :first_name, type: String
9
- field :last_name, type: String
10
- field :parent_title, type: String
11
-
12
- embeds_many :translations, validate: false
13
- embeds_one :language, as: :translatable, validate: false
14
- embedded_in :namable, polymorphic: true
15
-
16
- accepts_nested_attributes_for :language
17
-
18
- def set_parent=(set = false)
19
- self.parent_title = namable.title if set
20
- end
21
- end
@@ -1,5 +0,0 @@
1
- class Node
2
- include Mongoid::Document
3
- has_many :servers
4
- accepts_nested_attributes_for :servers
5
- end
@@ -1,12 +0,0 @@
1
- class Note
2
- include Mongoid::Document
3
- field :text, type: String
4
- field :saved, type: Boolean, default: false
5
- embedded_in :noteable, polymorphic: true
6
-
7
- after_save :update_saved
8
-
9
- def update_saved
10
- self.saved = true
11
- end
12
- end
@@ -1,6 +0,0 @@
1
- class OrderedPost
2
- include Mongoid::Document
3
- field :title, type: String
4
- field :rating, type: Integer
5
- belongs_to :person
6
- end
@@ -1,6 +0,0 @@
1
- class OrderedPreference
2
- include Mongoid::Document
3
- field :name, type: String
4
- field :value, type: String
5
- has_and_belongs_to_many :people, validate: false
6
- end
@@ -1,15 +0,0 @@
1
- class Oscar
2
- include Mongoid::Document
3
- field :title, type: String
4
- field :destroy_after_save, type: Boolean, default: false
5
- before_save :complain
6
-
7
- def complain
8
- if destroy_after_save?
9
- destroy
10
- true
11
- else
12
- false
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- class Override
2
- include Mongoid::Document
3
-
4
- def self.public_method
5
- end
6
-
7
- protected
8
-
9
- def self.protected_method
10
- end
11
-
12
- private
13
-
14
- def self.private_method
15
- end
16
- end
@@ -1,6 +0,0 @@
1
- module Ownable
2
- extend ActiveSupport::Concern
3
- included do
4
- belongs_to :user
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- class Owner
2
- include Mongoid::Document
3
- field :name
4
- has_many :events
5
- embeds_many :birthdays
6
- end
@@ -1,5 +0,0 @@
1
- class Page
2
- include Mongoid::Document
3
- embedded_in :quiz
4
- embeds_many :page_questions
5
- end
@@ -1,4 +0,0 @@
1
- class PageQuestion
2
- include Mongoid::Document
3
- embedded_in :page
4
- end
@@ -1,7 +0,0 @@
1
- class Palette
2
- include Mongoid::Document
3
- embedded_in :canvas
4
- embeds_many :tools
5
- end
6
-
7
- require "app/models/big_palette"
@@ -1,5 +0,0 @@
1
- class Parent
2
- include Mongoid::Document
3
- embeds_many :sub_items
4
- embeds_one :first_child, class_name: "Child", as: :childable
5
- end
@@ -1,6 +0,0 @@
1
- class ParentDoc
2
- include Mongoid::Document
3
- field :statistic
4
- field :children_order, type: Array, default: [] # hold all the children's id
5
- embeds_many :child_docs
6
- end
@@ -1,5 +0,0 @@
1
- class Passport
2
- include Mongoid::Document
3
- field :number, type: String
4
- embedded_in :person, autobuild: true
5
- end
@@ -1,9 +0,0 @@
1
- class Patient
2
- include Mongoid::Document
3
- field :title, type: String
4
- store_in collection: "inpatient"
5
- embeds_many :addresses, as: :addressable
6
- embeds_one :email
7
- embeds_one :name, as: :namable
8
- validates_presence_of :title, on: :create
9
- end
@@ -1,3 +0,0 @@
1
- class PdfWriter < Writer
2
- def write; end
3
- end
@@ -1 +0,0 @@
1
- class Pencil < Tool; end
@@ -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,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