mongoid_occurrences 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/mongoid_occurrences/has_occurrences.rb +4 -4
- data/lib/mongoid_occurrences/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c619b3bd83ad63138e51380cb82930144d2ae5ba273df95706fd8cdd6281c859
|
4
|
+
data.tar.gz: 9f6b20a19b1c3682db5be569f1075d0c40caf960564343ef6121dd1f5a168f55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8df2f048313e32a592d0eb81d41969119d3f848b36be7c670fb0a063483103eddf12b168db4e177b4ac507e30679f8a9f90ff04782d6ce07c3aaed0c02b55b6
|
7
|
+
data.tar.gz: 1d157cc26f4b63c722a6fb69623de09c35744772143e6b8d80f7205f34b6ce8bb27431af1237cae273bc10aac73578c44cb2810df404902fe2a09f890cc2790a
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,7 @@ module MongoidOccurrences
|
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
def embeds_many_occurrences(options = {})
|
9
|
-
field :
|
9
|
+
field :_previous_occurrences_cache_key, type: String
|
10
10
|
|
11
11
|
embeds_many :occurrences, class_name: options.fetch(:class_name)
|
12
12
|
accepts_nested_attributes_for :occurrences, allow_destroy: true, reject_if: :all_blank
|
@@ -14,7 +14,7 @@ module MongoidOccurrences
|
|
14
14
|
embeds_many :daily_occurrences, class_name: 'MongoidOccurrences::DailyOccurrence', order: :dtstart.asc
|
15
15
|
|
16
16
|
after_validation :assign_occurrences_cache_key!
|
17
|
-
after_validation :assign_daily_occurrences!, if: :
|
17
|
+
after_validation :assign_daily_occurrences!, if: :_previous_occurrences_cache_key_changed?
|
18
18
|
|
19
19
|
scope :occurs_between, ->(dtstart, dtend) { elem_match(daily_occurrences: DailyOccurrence.occurs_between(dtstart, dtend).selector) }
|
20
20
|
scope :occurs_from, ->(dtstart) { elem_match(daily_occurrences: DailyOccurrence.occurs_from(dtstart).selector) }
|
@@ -23,7 +23,7 @@ module MongoidOccurrences
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def occurrences_cache_key
|
27
27
|
last_timestamp = occurrences.unscoped.order(updated_at: :desc).limit(1).pluck(:updated_at).first
|
28
28
|
"#{occurrences.unscoped.size}-#{last_timestamp.to_i}"
|
29
29
|
end
|
@@ -45,7 +45,7 @@ module MongoidOccurrences
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def assign_occurrences_cache_key!
|
48
|
-
self.
|
48
|
+
self._previous_occurrences_cache_key = occurrences_cache_key
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|