Sha256: 6537f88a7a8dfa4549e0b05e8bb79ebf822f1695ab8cc8193bc9456379051205

Contents?: true

Size: 745 Bytes

Versions: 10

Compression:

Stored size: 745 Bytes

Contents

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

10 entries across 10 versions & 3 rubygems

Version Path
mongoid-3.1.7 spec/app/models/paranoid_post.rb
mongoid-3.1.6 spec/app/models/paranoid_post.rb
mongoid-3.1.5 spec/app/models/paranoid_post.rb
mongoid-paranoia-0.3.0 spec/app/models/paranoid_post.rb
mongoid-paranoia-0.2.1 spec/app/models/paranoid_post.rb
mongoid-versioning-0.2.0 spec/app/models/paranoid_post.rb
mongoid-paranoia-0.2.0 spec/app/models/paranoid_post.rb
mongoid-paranoia-0.1.1 spec/app/models/paranoid_post.rb
mongoid-versioning-0.1.0 spec/app/models/paranoid_post.rb
mongoid-paranoia-0.1.0 spec/app/models/paranoid_post.rb