mongocore 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +2 -2
- data/lib/mongocore.rb +1 -1
- data/lib/mongocore/document.rb +2 -2
- data/lib/mongocore/filters.rb +2 -2
- data/models/model.rb +1 -9
- data/mongocore.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d85eb2ea5445bfc95e054d6d1db6acd40a600d4
|
4
|
+
data.tar.gz: 9b164e319645a06750b6bbba78848007d9864cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6378aaa0c4548bcb15d67ae0ad34211ae5938c4d555be3022f40d0078d48151d6b95c33abdd4f151960d882e229c37694ef4e887eebcc1def9fcd70ff829c90
|
7
|
+
data.tar.gz: e936f449d87d351d095c86ef67517de817dc1e195bf6b14906ef0e7d9fb09d6f265c812e06d9c4d7c67925b428018a79eb7f46dad475b58f6d48742bcf56c02d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
**Version 0.4.2** - *2018-01-19*
|
2
|
+
|
3
|
+
- Reset model properly when doing a reload
|
4
|
+
- Removed update filter, both save and update uses the :save filter
|
5
|
+
|
6
|
+
|
7
|
+
**Version 0.4.1** - *2018-01-10*
|
8
|
+
|
9
|
+
- Automatically convert to Time for date if it's a Date or String
|
10
|
+
|
11
|
+
|
1
12
|
**Version 0.4.0** - *2017-12-01*
|
2
13
|
|
3
14
|
- Added each_with_index, each_with_object and map
|
data/README.md
CHANGED
@@ -217,7 +217,7 @@ class Model
|
|
217
217
|
errors[:goal] << 'you need a higher goal' if goal and goal < 5
|
218
218
|
end
|
219
219
|
|
220
|
-
# Before and after
|
220
|
+
# Before and after filters: :save, :delete
|
221
221
|
# You can have multiple blocks for each filter if needed
|
222
222
|
before :save, :setup
|
223
223
|
|
@@ -235,7 +235,7 @@ Mongocore.db[:models].find.to_a
|
|
235
235
|
Mongocore.db[:models].find({:_id => m._id}).first
|
236
236
|
|
237
237
|
# Indexing
|
238
|
-
Mongocore.db[:models].indexes.create_one(
|
238
|
+
Mongocore.db[:models].indexes.create_one(:key => 1)
|
239
239
|
Mongocore.db[:models].indexes.create_one({:key => 1}, :unique => true)
|
240
240
|
```
|
241
241
|
|
data/lib/mongocore.rb
CHANGED
data/lib/mongocore/document.rb
CHANGED
@@ -77,7 +77,7 @@ module Mongocore
|
|
77
77
|
|
78
78
|
# Update document in db
|
79
79
|
def update(a = {}, o = {})
|
80
|
-
self.attributes = a;
|
80
|
+
self.attributes = a; save(o)
|
81
81
|
end
|
82
82
|
|
83
83
|
# Delete a document in db
|
@@ -92,7 +92,7 @@ module Mongocore
|
|
92
92
|
|
93
93
|
# Reload the document from db and update attributes
|
94
94
|
def reload
|
95
|
-
one.first.tap{|m| self.attributes = m.attributes}
|
95
|
+
one.first.tap{|m| self.attributes = m.attributes; @original = m.attributes.dup; @changes.clear; @errors.clear}
|
96
96
|
end
|
97
97
|
|
98
98
|
# Set the timestamps if enabled
|
data/lib/mongocore/filters.rb
CHANGED
@@ -17,7 +17,7 @@ module Mongocore
|
|
17
17
|
@before = Hash.new{|h, k| h[k] = []}
|
18
18
|
|
19
19
|
# Add timestamp filters if enabled
|
20
|
-
[:save
|
20
|
+
@before[:save] << :timestamps if Mongocore.timestamps
|
21
21
|
|
22
22
|
# The after filters
|
23
23
|
@after = Hash.new{|h, k| h[k] = []}
|
@@ -31,7 +31,7 @@ module Mongocore
|
|
31
31
|
@validate.each{|k| call(k, m)}; m.errors.empty?
|
32
32
|
end
|
33
33
|
|
34
|
-
# Available filters are :save, :
|
34
|
+
# Available filters are :save, :delete
|
35
35
|
def run(m, f, key = nil)
|
36
36
|
send(f)[key].each{|k| call(k, m)}
|
37
37
|
end
|
data/models/model.rb
CHANGED
@@ -14,10 +14,6 @@ class Model
|
|
14
14
|
(@list ||= []) << 'before_save'
|
15
15
|
end
|
16
16
|
|
17
|
-
before :update do
|
18
|
-
(@list ||= []) << 'before_update'
|
19
|
-
end
|
20
|
-
|
21
17
|
before :delete do
|
22
18
|
(@list ||= []) << 'before_delete'
|
23
19
|
end
|
@@ -26,15 +22,11 @@ class Model
|
|
26
22
|
(@list ||= []) << 'after_save'
|
27
23
|
end
|
28
24
|
|
29
|
-
after :update do
|
30
|
-
(@list ||= []) << 'after_update'
|
31
|
-
end
|
32
|
-
|
33
25
|
after :delete do
|
34
26
|
(@list ||= []) << 'after_delete'
|
35
27
|
end
|
36
28
|
|
37
|
-
# Save,
|
29
|
+
# Save, delete
|
38
30
|
# before :delete, :hello
|
39
31
|
# after(:delete){ puts "Hello" }
|
40
32
|
|
data/mongocore.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mongocore'
|
3
|
-
s.version = '0.4.
|
4
|
-
s.date = '2018-01-
|
3
|
+
s.version = '0.4.2'
|
4
|
+
s.date = '2018-01-19'
|
5
5
|
s.summary = "MongoDB ORM implementation on top of the Ruby MongoDB driver"
|
6
6
|
s.description = "Does validations, associations, scopes, filters, pagination, counter cache, request cache, and nested queries. Using a YAML schema file, which supports default values, data types, and security levels for each key."
|
7
7
|
s.authors = ['Fugroup Limited']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongocore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|