mingo 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/lib/mingo.rb +3 -2
- data/lib/mingo/persistence.rb +1 -0
- data/lib/mingo/properties.rb +17 -6
- data/lib/mingo/timestamps.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0036923d82b82e64e030d6300cec95f78054ec51
|
4
|
+
data.tar.gz: 86d47c3cf07f078abbb2f662cfefb27b478f0fa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d00d70b34d4807748b7863a55c7ae244bfc68275ab51c6e0c333bd704b3d5c010235866dd0141839c860202eeb76466bd8668c9dd0b5f54f67f7f08efca7135
|
7
|
+
data.tar.gz: e051ec40e4d63b542f86bf892d6b9cc8fbdf1bf13841f2a939b8bdf9894566c566c43d52c96ecb3f06b24b9a7c4cd0d97f06ae3075712bfd4205ae1836a75c7c
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Mislav Marohnić
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/lib/mingo.rb
CHANGED
@@ -12,9 +12,10 @@ BSON::ObjectId.class_eval do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
class Mingo
|
15
|
+
class Mingo
|
16
16
|
include ActiveModel::Conversion
|
17
17
|
extend ActiveModel::Translation
|
18
|
+
extend ActiveModel::Naming
|
18
19
|
|
19
20
|
autoload :Properties, 'mingo/properties'
|
20
21
|
autoload :Cursor, 'mingo/cursor'
|
@@ -52,7 +53,7 @@ class Mingo < Hash
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def ==(other)
|
55
|
-
other.is_a?(
|
56
|
+
other.is_a?(Mingo) && other.id == self.id
|
56
57
|
end
|
57
58
|
|
58
59
|
def cache_key
|
data/lib/mingo/persistence.rb
CHANGED
data/lib/mingo/properties.rb
CHANGED
@@ -41,6 +41,11 @@ class Mingo
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def initialize(*)
|
45
|
+
super
|
46
|
+
@_data = {}
|
47
|
+
end
|
48
|
+
|
44
49
|
def inspect
|
45
50
|
str = "<##{self.class.to_s}"
|
46
51
|
str << self.class.properties.map { |p| " #{p}=#{self.send(p).inspect}" }.join('')
|
@@ -48,19 +53,25 @@ class Mingo
|
|
48
53
|
end
|
49
54
|
|
50
55
|
def [](field, &block)
|
51
|
-
|
56
|
+
@_data.send(:[], field, &block)
|
52
57
|
end
|
53
58
|
|
54
59
|
def []=(field, value)
|
55
|
-
|
60
|
+
@_data[field] = value
|
56
61
|
end
|
57
62
|
|
58
63
|
def to_hash
|
59
|
-
|
64
|
+
@_data.dup
|
60
65
|
end
|
61
66
|
|
62
|
-
|
63
|
-
|
64
|
-
|
67
|
+
def merge!(other)
|
68
|
+
@_data.merge!(other.to_hash)
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
def replace(other)
|
73
|
+
@_data.replace(other.to_hash)
|
74
|
+
self
|
75
|
+
end
|
65
76
|
end
|
66
77
|
end
|
data/lib/mingo/timestamps.rb
CHANGED
@@ -9,13 +9,13 @@ class Mingo
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def updated_at
|
12
|
-
self[
|
12
|
+
self['updated_at'] || created_at
|
13
13
|
end
|
14
14
|
|
15
15
|
protected
|
16
16
|
|
17
17
|
def touch_updated_timestamp
|
18
|
-
self[
|
18
|
+
self['updated_at'] = Time.now if changed?
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mingo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mislav Marohnić
|
@@ -36,6 +36,7 @@ executables: []
|
|
36
36
|
extensions: []
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
|
+
- LICENSE
|
39
40
|
- Rakefile
|
40
41
|
- lib/mingo.rb
|
41
42
|
- lib/mingo/callbacks.rb
|
@@ -49,7 +50,8 @@ files:
|
|
49
50
|
- lib/mingo/timestamps.rb
|
50
51
|
- spec/mingo_spec.rb
|
51
52
|
homepage: http://github.com/mislav/mingo
|
52
|
-
licenses:
|
53
|
+
licenses:
|
54
|
+
- MIT
|
53
55
|
metadata: {}
|
54
56
|
post_install_message:
|
55
57
|
rdoc_options: []
|