mongoid-falsehoods 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19ae9c57dfad65f292335eed952262330e7b4e5fc99a282786189e2b83a7d35f
4
- data.tar.gz: df33f08699f283940d3d1a6ddaae60bcee3458f4cb4f6ba1d348f2a885b4bada
3
+ metadata.gz: 407464f6a1fbdf5874a6fc9fed4078e11e29c094033e7ec2fda24d38b922310d
4
+ data.tar.gz: 71334edf9c8b803565ecc0bfc8ab88800f17a906eee89fa6dc709a6a9b97fca0
5
5
  SHA512:
6
- metadata.gz: dcf0106b4ae7af1e2307060d2b893f1e2b03ee0582c34347bc6f05e3b22f91bbc5c5c830bda339f6b50da047ae38decd60f46b8673bcbd8b0c6d3b063764564f
7
- data.tar.gz: 40ed04661e5416c9d74fbdee895b0db4fadfe96f7d8a9bccc2a43dec39b9975a927a4838756fc95fc4a06bd812c82d2b9a65a1e58fd4d9f75979cd838a6bb084
6
+ metadata.gz: e333fa8d6d4e63629e1250a25dc5524b9ddf41e5b89a02df535e7043578d2ce4ae44f29116c377897ffc41098185105a5c723f093ef7775e2ae5b1675935b323
7
+ data.tar.gz: 9d2aef19db5fc5e6b2ff2a5dec11b700b34526f86575a4a4b48a4bfde92af642dcc6f3a784b398a26cf0ac533a73bbc90879b6da012932ef116f00a5a714ea7b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ Support storing `false` for `Time` fields too.
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  Initial release with support for storing `false` instead of `null` for `DateTime` fields.
data/README.md CHANGED
@@ -22,12 +22,14 @@ Here's an example:
22
22
 
23
23
  ```ruby
24
24
  # before
25
- User.where(deleted_at: nil).explain['executionStats']['executionTimeMillis'] # 56
25
+ User.where(deleted_at: nil).explain['executionStats']['executionTimeMillis'] # 4197
26
26
  # after
27
- User.where(deleted_at: false).explain['executionStats']['executionTimeMillis'] #=> 41
27
+ User.where(deleted_at: false).explain['executionStats']['executionTimeMillis'] #=> 3055
28
28
  ```
29
29
 
30
- The improvement will vary based on the number of documents. That's with around 8000.
30
+ So by switching from `null` to `false`, we shaved off about a second from this query. The improvement will vary based on the number of documents. That's with around 790,000.
31
+
32
+ Hopefully Mongo will address [this Jira ticket](https://jira.mongodb.org/browse/SERVER-18861) at some point and make this gem unnecessary.
31
33
 
32
34
  ## Installation
33
35
 
@@ -29,4 +29,28 @@ module Mongoid
29
29
  end
30
30
  end
31
31
 
32
+ module Mongoid
33
+ module Extensions
34
+ module Time
35
+ module ClassMethods
36
+ alias_method :original_mongoize, :mongoize
37
+ alias_method :original_demongoize, :demongoize
38
+
39
+ def mongoize(object)
40
+ return false if object == false
41
+
42
+ original_mongoize(object)
43
+ end
44
+
45
+ def demongoize(object)
46
+ return false if object == false
47
+
48
+ original_demongoize(object)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
32
55
  ::DateTime.extend(Mongoid::Extensions::DateTime::ClassMethods)
56
+ ::Time.extend(Mongoid::Extensions::Time::ClassMethods)
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Falsehoods
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-falsehoods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Evans
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-11 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid