mongoid_extended 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -1
- data/Gemfile +2 -0
- data/README.md +5 -0
- data/lib/mongoid_extended/object_id.rb +2 -2
- data/lib/mongoid_extended/soft_delete.rb +25 -38
- data/lib/mongoid_extended/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40e985e628531c28fd5d0e392abda45e4dae86f5
|
4
|
+
data.tar.gz: 3bfd27ceaadfa5ecdad33a84eaa3f51056b043aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ccfb90e5543a0a17ce485efabb2a4fd0f8e7f16115588f00b9921fc393ae521645bddcd48dcd52a06eca8818e7a00137f338038efdfd0830469e8654d0a2c3
|
7
|
+
data.tar.gz: 6601d7be565383aeb7b03ee902ea0032387b5da7f018ebef943ecfa5a40c85d433caa2fdf7c97d87197d9749936df5b1e045fdbfc955d15160fcb4d2af06be11
|
data/.travis.yml
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
language: ruby
|
2
|
+
services:
|
3
|
+
- mongodb
|
2
4
|
rvm:
|
3
|
-
- 2.
|
5
|
+
- 2.0.0
|
6
|
+
- 2.1
|
7
|
+
- 2.2
|
8
|
+
env:
|
9
|
+
- USE_OFFICIAL_GEM_SOURCE=true
|
10
|
+
addons:
|
11
|
+
code_climate:
|
12
|
+
repo_token: b96c02b3cf400e79edcd08eaaefe6bfe82dc2fdf77c7dc09b1ce3d6a1040e124
|
4
13
|
before_install: gem install bundler -v 1.10.5
|
14
|
+
notifications:
|
15
|
+
recipients:
|
16
|
+
- neverlandxy.naix@gmail.com
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# MongoidExtended
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/NaixSpirit/mongoid_extended.svg?branch=develop)](https://travis-ci.org/NaixSpirit/mongoid_extended)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/NaixSpirit/mongoid_extended/badges/gpa.svg)](https://codeclimate.com/github/NaixSpirit/mongoid_extended)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/NaixSpirit/mongoid_extended/badges/coverage.svg)](https://codeclimate.com/github/NaixSpirit/mongoid_extended/coverage)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/mongoid_extended.svg)](https://badge.fury.io/rb/mongoid_extended)
|
7
|
+
|
3
8
|
Mongoid extended, Support EpochTime, ObjectId, Serializer, SoftDelete
|
4
9
|
|
5
10
|
## Installation
|
@@ -2,51 +2,38 @@
|
|
2
2
|
|
3
3
|
module MongoidExtended
|
4
4
|
module SoftDelete
|
5
|
-
|
6
|
-
def configured
|
7
|
-
add_class_method
|
8
|
-
add_instance_method
|
9
|
-
|
10
|
-
@configured = true
|
11
|
-
end
|
5
|
+
extend ActiveSupport::Concern
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
included do
|
8
|
+
field :deleted_at, type: DateTime
|
9
|
+
index({ deleted_at: -1 }, { background: true })
|
10
|
+
scope :undeleted, -> { where(deleted_at: nil) }
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
extend ActiveSupport::Concern
|
20
|
-
|
21
|
-
included do
|
22
|
-
field :deleted_at, type: DateTime
|
23
|
-
index({ deleted_at: -1 }, { background: true })
|
24
|
-
scope :undeleted, -> { where(deleted_at: nil) }
|
12
|
+
alias_method :destroy!, :destroy
|
13
|
+
end
|
25
14
|
|
26
|
-
|
27
|
-
|
15
|
+
def destroy
|
16
|
+
run_callbacks(:destroy) do
|
17
|
+
if persisted?
|
18
|
+
set(deleted_at: Time.now.utc)
|
19
|
+
set(updated_at: Time.now.utc) if respond_to?(:updated_at)
|
28
20
|
end
|
21
|
+
@destroyed = true
|
29
22
|
end
|
23
|
+
freeze
|
24
|
+
end
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
class_eval do
|
35
|
-
define_method :destroy do
|
36
|
-
run_callbacks(:destroy) do
|
37
|
-
if persisted?
|
38
|
-
set(deleted_at: Time.now.utc)
|
39
|
-
set(updated_at: Time.now.utc) if respond_to?(:updated_at)
|
40
|
-
end
|
41
|
-
@destroyed = true
|
42
|
-
end
|
43
|
-
freeze
|
44
|
-
end
|
26
|
+
def deleted?
|
27
|
+
!deleted_at.blank?
|
28
|
+
end
|
45
29
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
30
|
+
class << self
|
31
|
+
def configured
|
32
|
+
@configured = true
|
33
|
+
end
|
34
|
+
|
35
|
+
def configured?
|
36
|
+
!!@configured
|
50
37
|
end
|
51
38
|
end
|
52
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_extended
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spirit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.4.
|
141
|
+
rubygems_version: 2.4.5
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Mongoid Extended
|