Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Mongoid HEAD, Rails 5.0.0.rc1 #43

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ env:
services:
- mongodb

matrix:
include:
- rvm: 2.3.1
env:
- MONGOID_VERSION=HEAD
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
source 'https://rubygems.org'

case version = ENV['MONGOID_VERSION'] || '5'
when /^HEAD/
gem 'mongoid', github: 'mongodb/mongoid'
when /^5/
gem 'mongoid', '~> 5.0'
when /^4/
Expand Down
12 changes: 9 additions & 3 deletions lib/mongoid/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ def persisted?
# @return [ true ] True.
#
# @since 1.0.0
def remove_with_paranoia(options = {})
def remove(options = {})
cascade!
time = self.deleted_at = Time.now
_paranoia_update("$set" => { paranoid_field => time })
@destroyed = true
true
end
alias_method_chain :remove, :paranoia
alias :delete :remove

# Delete the paranoid +Document+ from the database completely.
Expand All @@ -114,7 +113,14 @@ def remove_with_paranoia(options = {})
#
# @since 1.0.0
def delete!
remove_without_paranoia
raise Errors::ReadonlyDocument.new(self.class) if readonly?
prepare_delete do
if embedded?
delete_as_embedded
else
delete_as_root
end
end
end

# Determines if this document is destroyed.
Expand Down