Sha256: 5691492f19abfb1fc7bc9f525aa65ae0632759b3154b90a41282a9aefc5a5cb1
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 Bytes
Contents
require 'mongoid/versioning' class ParanoidPost include Mongoid::Document include Mongoid::Versioning include Mongoid::Paranoia max_versions 2 field :title, type: String attr_accessor :after_destroy_called, :before_destroy_called belongs_to :person has_and_belongs_to_many :tags has_many :authors, dependent: :delete has_many :titles, dependent: :restrict scope :recent, -> { where(created_at: { '$lt' => Time.now, '$gt' => 30.days.ago }) } before_destroy :before_destroy_stub after_destroy :after_destroy_stub def before_destroy_stub self.before_destroy_called = true end def after_destroy_stub self.after_destroy_called = true end class << self def old where(created_at: { '$lt' => 30.days.ago }) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-paranoia-2.0.0 | spec/app/models/paranoid_post.rb |