mongoid_recurring 0.1.1 → 0.1.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: 94d65ba8e9128113f411305a33c0772f28ec8bdd
4
- data.tar.gz: eef1e3fa0d8780d7c249a057e69bf973b6ad5b5f
3
+ metadata.gz: d85b73b3c24c54091208f08e81cacb20de632f14
4
+ data.tar.gz: eac9e4fc14653e733a10d782a5b684f5bd4c1856
5
5
  SHA512:
6
- metadata.gz: 4513dff61f133e65a3395d95fd56cc595f811061ba94a9820d7ec0a8d4e0fc5931eaa31129842535fbf1606837ddc7eee520d7cfcceff010a9a651598f00b99b
7
- data.tar.gz: 3befbe40edcaf52f15117caa75ffea84cae1d06eab94c2d00695d5fc35a95fa81d355e472927be4ec25bcf84b1686b18616559463597e600209809b29aff4d70
6
+ metadata.gz: 0a01e15f26a9c90f8d3676a936fb031c912012db423407ba1af13a10b53960bcf31661b1b85f5acfa00d2600b3b3f28f9a4ffac8b700023838b1c6681cdf2382
7
+ data.tar.gz: 97aade14ef57dbfb29987a44fc5b7a2c2a7bc011d435b18e45e0d0d8ea1ad94c13802d4d249d9d6f3b97e0de3a4e1790875dbcac93b429c3a03fa002119ff5e6
@@ -35,19 +35,15 @@ module MongoidRecurring
35
35
  # ---------------------------------------------------------------------
36
36
 
37
37
  scope :for_datetime_range, -> (dtstart, dtend) {
38
- dtstart = dtstart.beginning_of_day if dtstart.instance_of?(Date)
39
- dtend = dtend.end_of_day if dtend.instance_of?(Date)
40
- where({ occurrences: { "$elemMatch" => { :dtstart.lte => dtend.to_datetime, :dtend.gte => dtstart.to_datetime } } })
38
+ where({ occurrences: { "$elemMatch" => Occurence.for_datetime_range(dtstart, dtend).selector } })
41
39
  }
42
40
 
43
41
  scope :from_datetime, -> (dtstart) {
44
- dtstart = dtstart.beginning_of_day if dtstart.instance_of?(Date)
45
- where( occurrences: { "$elemMatch" => { :dtstart.gte => dtstart.to_datetime } } )
42
+ where( occurrences: { "$elemMatch" => Occurence.from_datetime(dtstart).selector } )
46
43
  }
47
44
 
48
45
  scope :to_datetime, -> (dtend) {
49
- dtend = dtend.end_of_day if dtend.instance_of?(Date)
50
- where( occurrences: { "$elemMatch" => { :dtend.lte => dtend.to_datetime } } )
46
+ where( occurrences: { "$elemMatch" => Occurence.to_datetime(dtend).selector } )
51
47
  }
52
48
  end
53
49
  end
@@ -17,6 +17,24 @@ module MongoidRecurring
17
17
  before_save :set_dtend
18
18
  before_save :adjust_dates_for_all_day
19
19
 
20
+ # ---------------------------------------------------------------------
21
+
22
+ scope :for_datetime_range, -> (dtstart, dtend) {
23
+ dtstart = dtstart.beginning_of_day if dtstart.instance_of?(Date)
24
+ dtend = dtend.end_of_day if dtend.instance_of?(Date)
25
+ where( :dtstart.lte => dtend.to_datetime, :dtend.gte => dtstart.to_datetime )
26
+ }
27
+
28
+ scope :from_datetime, -> (dtstart) {
29
+ dtstart = dtstart.beginning_of_day if dtstart.instance_of?(Date)
30
+ where( :dtstart.gte => dtstart.to_datetime )
31
+ }
32
+
33
+ scope :to_datetime, -> (dtend) {
34
+ dtend = dtend.end_of_day if dtend.instance_of?(Date)
35
+ where( :dtend.lte => dtend.to_datetime )
36
+ }
37
+
20
38
  # =====================================================================
21
39
 
22
40
  def all_day?
@@ -1,3 +1,3 @@
1
1
  module MongoidRecurring
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_recurring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Celizna