regressor 0.5.1 → 0.5.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79c37f1dc82def55a51fbe5361c67c796bc323cf
|
4
|
+
data.tar.gz: 040a75add8d05a52af41705277be79aeec404d79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e756cccd3dccfdb1e0b96a7250d4c6eb2a70099934b517bb57b9d12b9bd3a50265c4452a7cd0da06c9e5f6992e9a597206c8f08a26f5e924c1858477477f3bd2
|
7
|
+
data.tar.gz: f6242b1742094db9396cfebf04cccb24a740237475e4a149ed766c2aada3b27c944b4521501120c0c6273e8aae368bd05d5a2aaee641fe3cfb27a4032f5519e7
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Regressor
|
2
|
+
module Model
|
3
|
+
module Mongoid
|
4
|
+
module Document
|
5
|
+
module Timestamp
|
6
|
+
def timestamp_includes
|
7
|
+
included_timestamp_modules.map do |module_included|
|
8
|
+
"it { is_expected.to #{timestamp_module(module_included)} }"
|
9
|
+
end.join("\n ")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def included_timestamp_modules
|
15
|
+
@model.included_modules.select do |module_included|
|
16
|
+
['Mongoid::Timestamps::Created', 'Mongoid::Timestamps::Updated', 'Mongoid::Timestamps'].include? module_included.to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def timestamp_module(module_included)
|
21
|
+
case module_included.to_s
|
22
|
+
when 'Mongoid::Timestamps'
|
23
|
+
timestamped_document
|
24
|
+
when 'Mongoid::Timestamps::Created'
|
25
|
+
timestamped_document_with_created
|
26
|
+
when 'Mongoid::Timestamps::Updated'
|
27
|
+
timestamped_document_with_updated
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def timestamped_document
|
32
|
+
'be_timestamped_document'
|
33
|
+
end
|
34
|
+
|
35
|
+
def timestamped_document_with_created
|
36
|
+
"#{timestamped_document}.with(:created)"
|
37
|
+
end
|
38
|
+
|
39
|
+
def timestamped_document_with_updated
|
40
|
+
"#{timestamped_document}.with(:updated)"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/model/mongoid_model.rb
CHANGED
@@ -3,6 +3,7 @@ require 'model/mongoid/relation/has_many'
|
|
3
3
|
require 'model/mongoid/relation/has_one'
|
4
4
|
require 'model/mongoid/relation/belongs_to'
|
5
5
|
require 'model/mongoid/relation/embedded'
|
6
|
+
require 'model/mongoid/document/timestamp'
|
6
7
|
|
7
8
|
module Regressor
|
8
9
|
module Model
|
@@ -13,6 +14,7 @@ module Regressor
|
|
13
14
|
include Mongoid::Relation::HasOne
|
14
15
|
include Mongoid::Relation::BelongsTo
|
15
16
|
include Mongoid::Relation::Embedded
|
17
|
+
include Mongoid::Document::Timestamp
|
16
18
|
|
17
19
|
# === Attribute Accessors ===
|
18
20
|
attr_accessor :model
|
data/lib/regressor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regressor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erwin Schens
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/model/active_record/validation/presence.rb
|
156
156
|
- lib/model/active_record_model.rb
|
157
157
|
- lib/model/mongoid/database/field.rb
|
158
|
+
- lib/model/mongoid/document/timestamp.rb
|
158
159
|
- lib/model/mongoid/relation/belongs_to.rb
|
159
160
|
- lib/model/mongoid/relation/embedded.rb
|
160
161
|
- lib/model/mongoid/relation/has_many.rb
|