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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f161200559e0992710c083b3d5ccb3e53cfcfa5
4
- data.tar.gz: 8262c4f5e071c729ecc5cb69a692cb50fde6478e
3
+ metadata.gz: 40e985e628531c28fd5d0e392abda45e4dae86f5
4
+ data.tar.gz: 3bfd27ceaadfa5ecdad33a84eaa3f51056b043aa
5
5
  SHA512:
6
- metadata.gz: 974734865d57e9761f3d7b1651776799caf6116fc14be4636875ce6150b68eb0798024d899b7f0a863029212fa5490d32be1bcc4127fb2a9e9b37c214aa87a02
7
- data.tar.gz: 10349d53834bbe2f80370f65e736c6cee5e01b07b1beffe2de046acf38f4d36e5735671211c73857e37c5f826ab55603bee85b9a4eeea34e0c1dc12723a58a32
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.1.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
@@ -7,3 +7,5 @@ end
7
7
 
8
8
  # Specify your gem's dependencies in mongoid_extended.gemspec
9
9
  gemspec
10
+
11
+ gem 'codeclimate-test-reporter', group: :test, require: nil
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
@@ -24,11 +24,11 @@ module MongoidExtended
24
24
  #
25
25
  # @since 2.0.0
26
26
  module HashRepresentation
27
- def to_json
27
+ def to_json(*args)
28
28
  to_s
29
29
  end
30
30
 
31
- def as_json
31
+ def as_json(*args)
32
32
  to_s
33
33
  end
34
34
  end
@@ -2,51 +2,38 @@
2
2
 
3
3
  module MongoidExtended
4
4
  module SoftDelete
5
- class << self
6
- def configured
7
- add_class_method
8
- add_instance_method
9
-
10
- @configured = true
11
- end
5
+ extend ActiveSupport::Concern
12
6
 
13
- def configured?
14
- !!@configured
15
- end
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
- def add_class_method
18
- instance_eval do
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
- alias_method :destroy!, :destroy
27
- end
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
- # Object.destroy is soft deleted
32
- # Object.delete is hard deleted
33
- def add_instance_method
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
- define_method :deleted? do
47
- !deleted_at.blank?
48
- end
49
- end
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
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module MongoidExtended
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  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.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-10-07 00:00:00.000000000 Z
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.7
141
+ rubygems_version: 2.4.5
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Mongoid Extended